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>
<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!
Related
I would like to generate documentation in a Dancer application in the same way that Mojolicious does with Mojolicious::Plugin::PODRenderer, I mean in the browser, under the /perldoc path.
Does somebody knows a module that can help? I found no ready-made plugin for Dancer. If it don't exist, any recommandation is welcome.
Porting Mojolicious' PODRenderer to Dancer should be fairly simple - it's an example plugin and the code is fairly short. I've done this for my own use in my CGI framework at work.
https://github.com/kraih/mojo/blob/master/lib/Mojolicious/Plugin/PODRenderer.pm#L34
Essentially what the plugin does is define the route /perldoc/:module to call the _perldoc method; the _perldoc method uses Pod::Simple::Search to find a documentation file matching the module param in the #INC directories; If it doesn't, it redirects the search to MetaCPAN. If it does, it uses Pod::Simple::HTML to convert the documentation to HTML, which is then tidied up with Mojo::DOM and wrapped in a lovely template.
Finding the location of that template is left as an exercise for... oh, nevermind, here it is: https://github.com/kraih/mojo/blob/master/lib/Mojolicious/templates/perldoc.html.ep
Is it possible to set an attribute in the soap:Body tag using perl and SOAP::Lite 0.7.
In all the examples I have seen I can change the attributes inside the body tag using
SOAP::Data * calls and use the $soap->call($dataValue) for this purpose.
What I really need is the way to add an ID attribute to the soap:Body tag in SOAP::Lite perl. Any pointers in this direction would be appreciated. Thanks.
Ok I think after banging my head on wall for 2days I should giveup using soap lite at client side and use raw xml for this purpose or use one of the alternates. I needed this to add the digital signatures. Found some suggestions to switch to SOAP::Simple/XML::Compile::SOAP. Any pointers in the direction would still be helpful. thanks
Also found out the way to have fine grain control via extending SOAP::Serializer and overriding the envelop method.
I read some info regarding getting .h files for undocumented API. Most of sources recommend class-dump (or class-dump-x and class-dump-z).
However it doesn't work with iPhone Security.framework. It doesn't contain Objective-C runtime information.
The only other way which I found is to use nm or otool. This will give the names of functions and disassembly for them.
Does anybody know some faster way to get undocumented functions signature than reading disassembly and trying to figure out what parameters go where and what could it be?
You mean this undocumented api, documented here..
Security.framework is not private or undocumented.
As far as headers go, installed on my harddrive in the 3.2 sdk i find:
/Security.framework/Headers/Security.h
/Security.framework/Headers/Secbase.h
/Security.framework/Headers/SecCertificate.h
/Security.framework/Headers/SecIdentitiy.h
/Security.framework/Headers/SecImportExport.h
/Security.framework/Headers/SecItem.h
/Security.framework/Headers/SecKey.h
/Security.framework/Headers/SecPolicy.h
/Security.framework/Headers/SecRandom.h
/Security.framework/Headers/SecTrust.h
As for a little reverse engineering 101, you should realise that a framework doesn't contain or in anyway have a use for header files, or function signatures. When provided they are solely for the benefit of the developer. There is no C or C++ or objective-c code in the compiled framework, only the raw machine code.
As you have seen, if objective-c was used Class-Dump can do a pretty good job of arranging objective-c symbols into something that looks like a header file, only missing type information that isn't used at runtime, so still not that useful.
If the source language was C then you are screwed. There may be a function name symbol but there is no info about arguments or return type.
There are bunch of additional undocumented API's which are not mentioned in official documentation. As example, part of them could be seen here:
http://www.opensource.apple.com/source/Security/Security-55163.44/sec/Security/
i have soap based Xml using that soap message i want to perform libxml parsing also perform lazy loading so how can i perform it please any one have idea about it then please help me.
Look at this sample code:
http://sourceforge.net/projects/mtgr8-a3/
Hope it helps.
Hello guys I'm looking for a way on the iPhone to parse an XML document using DOM. I have been using SAX with NSXMLParser but now I really want a DOM tree (or anything that can quickly translate the XML document into an NSDictionary)
Thanks for any help
If you want to use libxml2 with an Objective-C front without SAX events, take a look at this useful set of wrapper functions.
You issue an XPath query to your XML document object and get back Foundation class objects: NSArray, NSString, and NSDictionary, e.g.:
NSArray *queriedBuckets = PerformXMLXPathQuery(responseData, #"//*[local-name()='Buckets']/*[local-name()='Bucket']");
These functions help merge the speed of libxml2 with the readability and usability of Objective-C code.
Unfortunately, NSXMLDocument (which does what you're asking) does not exist on the iPhone. You may have to roll your own parser using libxml2, or try something like TouchXML or KissXML.
I suggest looking at the Google Data API for Objective-C (iPhone) at http://code.google.com/p/gdata-objectivec-client/
In particular, look at these files which define the GDataXMLNode class:
http://gdata-objectivec-client.googlecode.com/svn/trunk/Source/XMLSupport/