• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: XML elements by attributes
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: XML elements by attributes


  • Subject: Re: XML elements by attributes
  • From: email@hidden
  • Date: Wed, 14 Feb 2007 20:05:19 -0500

Assuming xml is your NSXMLDocument instance:

[xml nodesForXPath:@"//*[@region[.='bar']]" error:&error];

The XPath expression may not be perfect, but you get the idea. This method returns an array (NSArray) of NSXMLNode objects.

On Feb 14, 2007, at 6:32 PM, email@hidden wrote:

So I have gone through the docs on NSXMLDocument, Node, and Element. And I have some code that has been working for a while but is completely based on index numbers parse through it. Here is a very basic sample of what I am trying to do.

<root>
	<child name="foo">
		<tag>something</tag>
	</child>
	<child name="bar">
		<tag>something else</tag>
	</child>
</root>


What I want to do is grab the child node with the attributeWithName@"region" stringValue:@"bar"


There just does not seem to be a method to do this that I can figure out.
_______________________________________________


Cocoa-dev mailing list (email@hidden)

Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >XML elements by attributes (From: email@hidden)

  • Prev by Date: PDFMarkupAnnotations not showing when drawing PDFPage
  • Next by Date: Re: Frustration trying to get NSConnection/NSPort working (feels like it should be simpler ...)
  • Previous by thread: XML elements by attributes
  • Next by thread: Frustration trying to get NSConnection/NSPort working (feels like it should be simpler ...)
  • Index(es):
    • Date
    • Thread