Basic XPath Question
Basic XPath Question
- Subject: Basic XPath Question
- From: "Mac QA" <email@hidden>
- Date: Thu, 3 Apr 2008 16:40:07 -0400
Hi,
I am trying to use the nodesForXPath:error: API to search an XML
document and find particular nodes. For example, my document has
multiple entries for various hosts that look something like this:
<host name="intel-mini.local">
<user name="a">
<run command="/beep" arguments="5">
</run>
</user>
</host>
So I want to craft an XPath to search the document in order to find
this specific host node. Currently, I am crafting my XPath string like
so:
NSString *xPath = [NSString
stringWithFormat:@"//host[@name=\"%@\"]",newHostname];
And I have also tried:
NSString *xPath = [NSString
stringWithFormat:@"//host[attribute::name=\"%@\"]",newHostname];
However neither work for finding this particular host node. Yet, when
I use the following XPath I can get an array of all the host nodes.
NSString *xPath = [NSString stringWithFormat:@"//host"];
Does the nodesForXPath:error: API in Cocoa just not support the
features of XPath for matching nodes with specific attribute values?
Or am I just doing something totally wrong? Any suggestions or
pointers to examples would be greatly appreciated. Thanks!
_______________________________________________
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