• 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 XPath question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: XML XPath question


  • Subject: Re: XML XPath question
  • From: Chris Patterson <email@hidden>
  • Date: Wed, 1 Oct 2008 12:47:44 -0400

I am trying to retrieve some specific data from a XML document.

<data>
	<department>
		<employe id="1">
			<name>abcd</name>
		</employe>
		<employe id="2">
			<name>efrh</name>
		</employe>
		<employe id="3">
			<name>ijkl</name>
		</employe>
		<employe id="4">
			<name>mnop</name>
		</employe>
	</department>
</data>

so I'm trying to query the XML document with the following XPath string.

[... stringWithFormat:@".//data/department/employe[id=\"%@\"]",
[employeID stringValue]]

this returns no objects.

Your XPath is almost correct, as far as I can tell. All you need to do is insert an "@" character before the "id" attribute predicate, like so:


".//data/department/employe[@id=\"%@\"]"

================================================================
Chris Patterson       chris dot s dot patterson at gmail dot com
"The only problem with Microsoft is they just have no taste."
 -- Steve Jobs <http://www.youtube.com/watch?v=WfALGcDNEDw>
================================================================



_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please 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


  • Follow-Ups:
    • Re: XML XPath question
      • From: Sandro Noel <email@hidden>
  • Prev by Date: Re: [Moderator] Please hold off on iPhone SDK discussions until the rules are clarified later today
  • Next by Date: Re: command line tool: processing files dropped on it?
  • Previous by thread: XML XPath question
  • Next by thread: Re: XML XPath question
  • Index(es):
    • Date
    • Thread