I have an XML file. Root is called document. document has several elements and nodes. In the middle, there are n number of documentFile elements. documentFile has some nodes. I would like to add 0 or more documentFile elements right after the last occurrence of documentFile
So I have something like:
<document>
<someTags>
<documentFile>
<someSubTags>
<documentFile>
<someSubTags>
<someMoreTags>
</document>
I have tried using the following code:
GDataXMLDocument *tabsTree = [[GDataXMLDocument alloc]initWithData:tabsTreeData
encoding:NSUTF8StringEncoding
error:nil];
GDataXMLElement *rootElement = [tabsTree rootElement];
[rootElement addObject:[self createGDataXMLElementForDocumentFile:tab]];
As expected, this adds documentFile element to the end of the XML.
I have also tried
GDataXMLElement *rootElement = [tabsTree rootElement];
GDataXMLElement *documentFile = (GDataXMLElement *) [rootElement
elementsForName:kDocumentFile][0];
[documentFile addChild:[self createGDataXMLElementForDocumentFile:tab]];
This adds the documentFile element as the child of the first occurrence of documentFile, which is not surprising either.