I am trying to update an XML file. After the suggestion I ended up choosing GdataXml. That's why I'm trying to update the options.xml file.
Original file
& lt; Dat & gt; & Lt; Name & gt; Tom & lt; / Name & gt; & Lt; Options & gt; 1 & lt; / Options & gt; & Lt; / Dat> I need to change "Tom" in "Jim" and save it in the same file
Whatever code I have tried here.
- (zero) Bhaitex ML {NSString * path = [[NSBundle main bundle] Pathfoser resource: @ "option" type: @ "xml"]; NSDTA * XMLDITA = [[NSMUtableDataAloc] Invite content offile: path]; NSError * error; GDATXML Document * DOC = [[Gdataxml Document ALOOC] Init Withdata: XMLLtata Option: 0 Error: and Edition]; GdaAT XMLML * Route Element = [GdATXMelectionTourism: @ "DAT"]; NSArray * mySettings = [doc.rootElement elementsForName: @ "Dat"]; (For MySet in GDataXMLElement * mySettings) {NSString * names; NSArray * name = [mySet elementsForName: @ "name"]; If (names.count & gt; 0) {GDataXMLElement * childElement = (GDataXMLElement *) [Name objectAtIndex: 0]; Name = child element.brindwhole; NSLog (childElement.stringValue); [Child Element Setting Value: @ "Jim"]; }} [XmlData writeToFile: path atom: yes]; } but it is not updating the options.xml file. Can anyone help on this?
The code you are looking for
NSDT * xmlData = doc .XMLData; From your last question to you are currently reading a file in memory, using that memory, starting a new object, updating that new object And then writing the original file's memory in the new file location. So basically you are reading a file and then writing the same file at the file location.
No comments:
Post a Comment