|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|
|iPad Mini: Anyone switch from reading on a Paperwhite to reading on the rMini?||Frankied22||iPad||48||May 23, 2014 02:16 AM|
|Mp3 file attributes||cool11||Digital Audio||0||Oct 17, 2013 02:02 PM|
|PDF Attributes simple tool for editing PDF attributes||Alex Aperio Lux||Mac Applications and Mac App Store||0||Apr 8, 2013 05:17 PM|
|Free app for offline reading (only reading ) PDF, WORD, EXCEL, PPT files||Subu||iPhone and iPod touch Apps||0||Feb 21, 2013 11:43 PM|
|Removing document attributes/metadata||gax23||OS X||1||Aug 21, 2012 03:40 AM|
All times are GMT -5. The time now is 07:01 PM.