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

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

  • Follow-Ups:
    • Re: Basic XPath Question
      • From: Jens Alfke <email@hidden>
  • Prev by Date: Re: Bindings on Contextual Menu Items when to unbind:
  • Next by Date: Re: how to hack my own apps
  • Previous by thread: Re: how to hack my own apps
  • Next by thread: Re: Basic XPath Question
  • Index(es):
    • Date
    • Thread