Skip navigation.
 
mlXML XPath question
FROM : Sandro Noel
DATE : Wed Oct 01 17:39:31 2008

Greetings.

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.

if i try the same line without th attribute in the query
[".//data/department/employe"]

I receive an array with all the employe records, witch is the expected 
behavior.

what am I doing wrong in the first query, the documentation says this.
.//part/chapter[1]/section[title="Path Expressions"]
The evaluation of a path expression works from left to right. This 
expression first gets all the elements named part and from that 
selects the first element named chapter; from that it gets all child 
elements named section, and from that sequence it returns the section 
element whose title is “Path Expressions”. XPath also lets you find 
attributes by name by using an at-sign (@) prefix. For example, the 
following path expression gets the modification date (an attribute) of 
the first chapter:



Thank you any help is appreciated.

Sandro._______________________________________________

Cocoa-dev mailing list (<email_removed>)

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:
http://lists.apple.com/mailman/options/cocoa-dev/<email_removed>

This email sent to <email_removed>

Related mailsAuthorDate
mlXML XPath question Sandro Noel Oct 1, 17:39
mlRe: XML XPath question Chris Patterson Oct 1, 18:47
mlRe: XML XPath question Sandro Noel Oct 1, 19:32