Accessing attributes of XML
Accessing attributes of XML
- Subject: Accessing attributes of XML
- From: "Christian Graus" <email@hidden>
- Date: Mon, 5 May 2008 22:34:24 +1000
Hi, I have the following code:
NSXMLDocument *doc = [[NSXMLDocument alloc] initWithContentsOfURL:xmlURL
options:0 error:&error];
NSXMLNode *node = [doc rootElement];
NSArray *array = [node nodesForXPath:@"/DiaIndex/Item"
error:&err];
int nodeCount = 0;
while(nodeCount < 1300)
{
NSXMLElement *node2 = [array objectAtIndex:nodeCount];
NSXMLElement *name = [node2 attributeForName:@"Name"];
NSString * n = [name stringValue];
NSArray * attr = [node2 attributes];
int count = [attr count];
++nodeCount;
}
I cut out some code to simplify, if you spot an error that would stop it
compiling, that code is there. I am getting the correct number of Item
nodes, but I cannot work out how to access the inner Text of the node ( I am
used to having the DOM to work with ), and when I search for an Attribute,
name does not appear to be null, but it's stringValue is. The attributes
collection should be 15 odd objects, and it's 0. Any help on how to search
and extract attribute values would be appreciated.
Thanks
Christian
_______________________________________________
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