libxml2 xml parsing issue

wmtmeocon

New Member
I have an xml file which i create myself.\[code\] <?xml version='1.0' encoding='utf-8' ?> <Root> <ChildElements> <type name='xx' attr='false'> <child id='1' regex='^[0-9]{11}$'> <BBB> <node1 name='aaa' regex='\w{5}'/> <node2 name='bbb' regex='\w{3}'/> </BBB> </child> <child> . . . </child> </type> </ChildElements> </Root>\[/code\]Something like this. I want to parse it to xml document object and iterate through its nodes, I'm using libxml2 for ios.\[code\] NSString *xmlPath = [[NSBundle mainBundle] pathForResource:@"xmlcontent" ofType:@"xml"]; NSData *xmlData = http://stackoverflow.com/questions/10798140/[NSData dataWithContentsOfFile:xmlPath]; NSString* xml = [[NSString alloc ] initWithData:xmlData encoding:NSUTF8StringEncoding];int size=[xml lengthOfBytesUsingEncoding:NSUTF8StringEncoding]; xmlDocPtr docptr=xmlParseMemory([xml UTF8String], size);\[/code\]but in docptr object there is only one node, which is Root node, and when I try to get Root node child nodes it returns an empty node which name is @"text".
NSXMLParser easily parses the same XML, but I don't know how to create a document and iterate through nodes by using NSXMLParser.
 
Back
Top