I want to parse an xml file using libxml2 and XPath
I have tried to look this up on the internet but I can't find much about it.
Can anyone give me a sample code for parsing this xml:
<WebServiceResponse>
<status>OK</status>
<result>
<type>sample</type>
<name>Sample XML</name>
<location>
<lat>37.4217550</lat>
开发者_StackOverflow<lng>-122.0846330</lng>
</location>
</result>
<result>
<message>The secret message</message>
</result>
</WebServiceResponse>
just so I can work further
thanks in advance
this link may help you,
xml parsing iphone, objective C?
two automatic source creating: http://sudzc.com/
Download wsdl2objc and usage instructions here: http://code.google.com/p/wsdl2objc/wiki/UsageInstructions
Actually I am also looking for the code, please update once you find the answer.
You say you want to use libxml2 and XPath, but you don't say what you need XPath (presumably libxml2's implementation of the XPath 1.0 spec) to do. You ask for sample code to parse the XML, but you don't say what you want to do with the information in the XML, so it's hard answer your question.
If you really want to use libxml2, then you'll be writing most of your code in C because libxml2 is a C library. I recommend you use the libxml2 tutorial to get started. Based on that you should be able to try out some things. If you then have specific problems that you need to help with you can post more specific questions.
If you're not really committed to using libxml2 directly, and you prefer to write something more "native-like" in objective-C, then there are numerous frameworks for doing that including the built-in NSXMLParser class. There's no direct support for XPath or full-document XML processing built-in for iOS, but if what you want to do is parse the XML it should be relatively straightforward.
Good luck!
精彩评论