A Simple NSXML XPath Problem
A Simple NSXML XPath Problem
- Subject: A Simple NSXML XPath Problem
- From: Bing Li <email@hidden>
- Date: Sun, 29 May 2011 10:40:24 +0800
Dear all,
I got a problem when extracting data from XML using NSXML and XPath. When
doing the same thing using Java, it works fine. But using NSXML and XPath,
the result is different.
The XML is pretty simple.
<?xml version="1.0" encoding="UTF-8"?>
<addresses>
<road>Orange ST</road>
<apt>RM235</apt>
</addresses>
The following code is use to extract the value of the road, "Orange ST". In
Java, the XPath is the same, i.e., /addresses/road.
NSError *err = nil;
NSArray *nodes = [xmlDoc nodesForXPath:@"/addresses/road" error:&err];
for (int i = 0; i < [nodes count]; i ++)
{
NSLog(@"%@", [nodes objectAtIndex:i]);
}
But the result is as follows, not "Orange ST".
<road>Orange ST</road>
Thanks so much!
Bing
_______________________________________________
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