• 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: xpath id() function
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: xpath id() function


  • Subject: Re: xpath id() function
  • From: Jonathan Wight <email@hidden>
  • Date: Fri, 12 Aug 2005 17:34:17 -0400

In case a code example would help get an answer here one is:

#import <Foundation/Foundation.h>

int main (int argc, const char * argv[])
{
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];

NSString *theXMLString = @" \
<foo> \
<bar id=\"xyzzy\"/> \
</foo> \
";
NSError *theError;
NSXMLDocument *theDocument = [[[NSXMLDocument alloc] initWithXMLString:theXMLString options:0 error:&theError] autorelease];
NSLog(@"%p", theDocument);


NSArray *theNodes = [[theDocument rootElement] nodesForXPath:@"/foo/ bar" error:&theError];
NSLog(@"%@", theNodes);


theNodes = [[theDocument rootElement] nodesForXPath:@"id('xyzzy')" error:&theError];
NSLog(@"%@", theNodes);


[pool release];
return 0;
}

Both the XPath fetch methods should return the same result...

    Jon.

On Aug 12, 2005, at 14:35, Jonathan Wight wrote:

Does the xpath function id() work inside "-[NSXMLNode nodesForXPath:error:]"?

I should be able to call:

NSArray *theResult = [[[inNode rootDocument] rootElement] nodesForXPath:@"id('tk421') error:&theError];

On an NSXMLElement that looks like this:

<things>
    <sthing id="tk421">...</thing>
</things>

And get back the relevent set of nodes (in this example just a single node)...

But instead I am getting an empty array returned and no error return in the error parameter.

Jon.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >xpath id() function (From: Jonathan Wight <email@hidden>)

  • Prev by Date: NSTextView and vertical glyphs
  • Next by Date: Re: NSTextView and vertical glyphs
  • Previous by thread: xpath id() function
  • Next by thread: Newbie Button Matrix / Bindings
  • Index(es):
    • Date
    • Thread