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:@"//[EMAIL PROTECTED]"[EMAIL PROTECTED]"]",newHostname];

And I have also tried:

NSString *xPath = [NSString
stringWithFormat:@"//host[attribute::name=\"[EMAIL PROTECTED]"]",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 (Cocoa-dev@lists.apple.com)

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/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to