My favorites | Sign in
Project Home
READ-ONLY: This project has been archived. For more information see this post.
Search
for
  Advanced search   Search tips   Subscriptions
Issue 9: Relative xpaths don't work
1 person starred this issue and may be notified of changes. Back to list
Status:  Fixed
Owner:  jwight
Closed:  Apr 2008


 
Project Member Reported by jwight, Apr 7, 2008
Broken out from  issue #4 

I've got this working with a default namespace, but I'm having trouble figuring out the syntax for 
relative paths-- those starting with 
"./".  For example, with my XML document, I can look up "track" nodes with:

	NSArray *trackNodes;
	NSDictionary *namespaceMappings = [NSDictionary 
dictionaryWithObjectsAndKeys:@"http://xspf.org/ns/0/", @"seeqpod", nil];
	trackNodes = [rootElementC nodesForXPath:@"//seeqpod:track" 
namespaceMappings:namespaceMappings error:&error];

But each track node has a child named "location".  With NSXML I can grab that with:

	for (NSXMLNode *currentTrack in trackNodes) {
		NSArray *locationNodes = [currentTrack nodesForXPath:@"./location" error:&error];
		...
	}

With TouchXML, I tried it this way and get zero hits:

	for (CXMLNode *currentTrack in trackNodes) {
		NSArray *locationNodes = [currentTrack nodesForXPath:@"./seeqpod:location" 
namespaceMappings:namespaceMappings 
error:&error];
		...
	}

I tried a number of variations on the path-- "seeqpod:./location", "seeqpod:./seeqpod:location", 
etc.  Is this another case of NSXML 
abusing the XPath spec, or have I just not found the magic cookie?


Apr 7, 2008
Project Member #1 jwight
Fixed in r57. 1 Unit test added.
Status: Fixed
Labels: TouchXML

Powered by Google Project Hosting