I am trying to parse following xml using tbxml library -
<?xml version="1.0" encoding="UTF-8"?>
<REPLY replyCode="Success" >
<TRACK track_id="1302234" track_mp3="74-Ruff_Ryders_feat_Sheek_Louch_and_Big_Pun_-_Piña_Colada.mp3"></TRACK>
</REPLY>
But when I tried to create TBXML object the app is crashing I think this is because of some special chars in xml file (Piña).
Any idea on this?
Latest version 1.4 resolved this problem!!
Related
I am trying to parse HTML URL content using hpple for iPhone app. I want to parse and get data from like this URL http://www.example.com/mobile/403.html. I have used Google and found hpple for HTML parsing. I got the sample HTML parsing hpple code from github. When i start to run the project the below error is occurring
'libxml/tree.h' file not found
I have added this line ${SDKROOT}/usr/include/libxml2 in project->build->header search paths but not it is looking like this iPhoneos3.1.2/usr/include/libxml2/** and also i have included libxml2.dylib and libxml2.2.dylib in my project. Am working in XCode 4.2. Could you please help to solve this error? Thanks in advance.
Make sure you add this line:
${SDKROOT}/usr/include/libxml2
in TARGETS->build->header search paths...
and make sure that you copied your hpple files into your project like this...
Good luck and hope this helps!
I want to create XML string to be sent to server through web-service. How do I do it natively in iPhone? Or do I have to use any third party library?
I was not able to download GDATA for iPhone. Any else available? Or any other way to do it?
Please help,
Thanks in advance.
You can create XML file with StringWithFormat method or Some of XML parser allow write XML as well. Please refer link of Parser for writing XML
http://www.raywenderlich.com/553/how-to-chose-the-best-xml-parser-for-your-iphone-project
You can use JSON parser also....
You may want to refer to SBJSON Framework which is frequently used for objective-C, I have used this framework in may of my iOS Apps.
You may get a reference about it from these links:
https://github.com/stig/json-framework
http://stig.github.com/json-framework/
Example Code: Also here is an example on, How to parse JSON with SBJSON Parser:
How to parse JSON into Objective C - SBJSON
http://jasarien.com/?p=428
I used KissXML in my project, now I wanna dump XML info for trace like Zend_Debug::dump(XXX) in php.
But I failed to find API support in KissXML.
Any Idea? or I have to implement by myself?
Thanks!
You can use the description message, or event better, [xml XMLStringWithOptions:DDXMLNodePrettyPrint]
I just want a tutorial demonstrating the parsing of XML File using libXml2 in Iphone . I found tutorials on TouchXMLand other but not the same for Libxml2
Please help if u can.
Apple has an example iPhone project that parses some simple XML using both NSXMLParser and libxml2 SAX2. You can find the project here:
http://developer.apple.com/iphone/library/samplecode/XMLPerformance/Introduction/Intro.html
Although this isn't exactly a tutorial, it is working code. It runs in the simulator out of the box. Because it accomplishes the same task twice, you should be able to compare the libxml2 code to the NSXMLParser code to figure out what's going on.
Not even these?
I recommend TBXML. I use it everytime I need to parse a XML File. It's really easy to use. ;-)
See here: TBXML Homepage
A good sample is:
http://bill.dudney.net/roller/objc/entry/libxml2_push_parsing
i noticed strange problem in sdk 3.0.
When i parse XML everything works fine in any sdk 2.x but sdk 3.0 doesn't it.
I didn't find any difference in NSXMLParser but any 2.x sdk works fine and 3.0 doesn't.
If anybody met such problem and tell me how to u solve it?
->
rssParser is NSXmlParser object.
In sdk 3.0
i call this method.[rssParser parse];
then the first method my parser called is this
(void)parser:(NSXMLParser *)parser parseErrorOccurred:(NSError *)parseError
and after that it does nothing.
when i select sdk 2.2.1
then also it calls this method
(void)parser:(NSXMLParser *)parser parseErrorOccurred:(NSError *)parseError
but parser doesn't stop parsing it continue with calling other delegates of NSXmlParser.
Parse error is same in both
Error 65,Description: (null), Line: 1, Column: 60
This is the first line
!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" with < > on both end
Well, you are trying to parse a HTML file with NSXMLParser. An NSXMLParser needs a valid XML file and HTML files aren't valid XML files, they could be, but almost all are not. The doctype for instance isn't valid XML. Your using the wrong "tool" for the job.
The reason why it doesn't work on 3.x, but does on 2.x is not known to me, looks like there has been a change in behaviour after all.
I'd suggest using libxml2 to parse the HTML file and not NSXMLParser. Libxml2 can be used to parse "real world" HTML.
You might want to look at this StackOverflow topic:
parsing HTML on the iPhone
Actually the problem is that in 3.0 NSXmlparser is more restrict and it will not parse any file in 3.0 which contain any error.Answer given by Yannick Compernol is correct.to sove the problem I used libxml2.You can see this link to get the code for the parsing
http://cocoawithlove.com/2008/10/using-libxml2-for-parsing-and-xpath.html
It sounds like there's an error in your xml that the 2.x parser could get past but the 3.0 parser is more strict and stops.
Can you post the smallest xml you can make that causes this error?
Sam
My xml file contains an error
after removing , the problem is solved.
i dont know why it was working fine for NSXMLParser in OS 2.2.1.May be that ignore error in xml file.