Search code examples
iphonexmlcocoa-touchnsxmlparsernsxml

NSXML Parsing - Distinguishing Nodes


I am trying to extract the doc-num from the following xml using NSXML. At this point I am able to iterate through all the nodes using the NSXML parser event, but I am trying to distinguish between the doc-num in the input node from the one in the output node.

How can I do this? I am a bit lost on how to get this to work for my iphone app. Also, is there a simpler way than the event based NSXML?

     <xmt:input>
        <xmt:app-refer>
            <doc-id doc-id-type="docdb">
                <country>MD</country>
                <doc-num>20050130</doc-num>
                <kc>A</kc>
                <date>20050130</date>
            </doc-id>
        </xmt:app-refer>
    </xmt:input>
    <xmt:output>
        <xmt:app-refer>
            <doc-id doc-id-type="epodoc">
                <doc-num>MD20050000130</doc-num>
                <date>20050130</date>
            </doc-id>
        </xmt:app-refer>
    </xmt:output>

Solution

  • Here is a tutorial that shows XML parsing using GDataXMLParser.

    how-to-read-and-write-xml-documents-with-gdataxml

    GDataXMLParser is better than NSXMLParser since latter is slower.