|Jul 29, 2009, 08:58 PM||#1|
XML attributes and reading what they are
ok, this is going to sound really stupid...
i can add an attribute to a node easily enough and append it to another node
NSXMLNode* attr = [[NSXMLNode alloc] initWithKind: NSXMLAttributeKind]; [attr setName: @"testAttr"]; [attr setStringValue: @"testVal"]; [root addChild: [NSXMLNode elementWithName: @"testNode" children: nil attributes: [NSArray arrayWithObject: attr]]];
now... how do i read that value back (specifically from a file, not when i just created it)?
I saw that you can get/set attribute values for an NSXMLElement which is a subclass of NSXMLNode
so how do i get the attributes of an NSXMLNode?
eeeh, nevermind, i missed the part where NSXMLDocument returns an NSXMLElement when you call rootNode
oh wait, that's right... NodesForXPath returns an NSArray of NSXMLNode
is it possible to get the attribute name and value from an NSXMLNode?
pfff, i knew this was a stupid question! just needed a few minutes to experiment more
found me what i was after
NSXMLNode* rootTwo = [xmlDoc rootElement]; NSArray* pathNodes = [rootTwo nodesForXPath:@"/singQToRenderQ/testNode" error: nil]; NSXMLElement* elementNode = [pathNodes objectAtIndex: 0]; NSArray* attributesFromElement = [elementNode attributes]; NSXMLNode* theAttributeNode = [elementNode attributeForName: @"testAttr"];
Last edited by Chirone; Jul 29, 2009 at 09:35 PM.
|Thread Tools||Search this Thread|
|thread||Thread Starter||Forum||Replies||Last Post|
|What??? They are removing Unlimited Data??||greytmom||iPhone||2||Oct 7, 2011 04:25 AM|
|When I Go To Youtube And Watch Videos They Are Very Slow, Audio Is Fine, Please Help?||petedogz||Mac Basics and Help||5||Jan 18, 2010 01:25 PM|
|Mac os x installation problems. Anyone know what they are doing? Please help!!||Ashleyhall19||OS X||13||Aug 8, 2009 07:31 PM|
|Bindings - would someone explain what they are?||glossywhite||iPhone/iPad Programming||8||Apr 6, 2009 08:01 PM|
|why Jobs is Jobs and how computers became what they are today.||sillycybin||General Mac Discussion||11||Jan 22, 2006 12:06 PM|
All times are GMT -5. The time now is 03:42 PM.