Retrieve resolution file path
Nsstring * xmlpath = [[nsbundle mainbundle] pathforresource: @ "person" oftype: @ "XML"];
2. Initialize an XML string
Nsstring * xmlstr = [nsstring stringwithcontentsoffile: xmlpath encoding: nsutf8stringencoding error: Nil];
3. initialize a gdataxmldocument object, because all the content during parsing is obtained from this object (so you need to put the content to be parsed into this object)
Gdataxmldocument * Document = [[gdataxmldocument alloc] initwithxmlstring: xmlstr options: 0 error: Nil];
If XPath is given a relative path, such as // name. If it can reach the name, the name can be obtained.
Retrieve all Name nodes
Nsarray * nameelement = [document nodesforxpath: @ "// name" error: Nil];
Get all gender nodes
Nsarray * genderelement = [document nodesforxpath: @ "// gender" error: Nil];
Retrieve each node cyclically
For (INT I = 0; I <3; I ++ ){
Gdataxmlelement * nameele = nameelement [I];
Gdataxmlelement * genderele = genderelement [I];
Take the string in the node attribute
Nsstring * A = [[nameele attributeforname: @ "name"] stringvalue];
Get node string
Nsstring * name = [nameele stringvalue];
Nslog (@ "AAA ddddd % @", );
}
XML parsing dom (2)