My xml is
<categoryname>Baby</categoryname>
<id>244</id>
<categoryname>Boats & Watercraft</categoryname>
<idc>1026</id>
I am getting first two nodes.My problem is the third node i am getting Boats only (parser foundCharacters) and & kills the nsxmlparser. I am searching this forum and other websites most of them post use & instead of & in xml . My xml is coming from server and i wont update xml now.Is there any other option to solve this issue.
If you insist on sending invalid XML from your server this should solve it:
[xmlString stringByReplacingOccurrencesOfString:#"&" withString:#"&"]:
// parse xmlString
[categoryName stringByReplacingOccurrencesOfString:#"&" withString:#"&"]:
If your xml might be coming from some php script then before sending it you have to make change in your script that when & character occurs it substitute with other character like $ or any other and then send it. And when you parse that xml change that symbol to your required symbol.
I have also done the same thing.
Related
I am using TBXML Parser ver. 1.4, When I am Parsing this kind of following responce via TBXML parser, getting EXC_BAD_ACCESS...
<trainingOrganization xsi:type="xsd:string">~!##$%^&*()_+?> <,./;'{}|<":;'></trainingOrganization>
Stuck with this issue.
As I observe that <> data is failed to parse by TBXML...
Thanks in Advance.
One of the best way to use CDATA, anything inside of CDATA treat as xml document so if you have special character like ';:,.''<>' then parser will ignore it. So I always prefer to use CDATA and advise you to should use it.
I think it's nothing TBXML parser specific.
Chars like <>\"' have to be masked (by a \), so it's maybe only the coding of your xml file or the settings for its parsing.
Otherwise the parser thinks it is :
<trainingOrganization xsi:type="xsd:string">
~!##$%^&*()_+?
> *<-- closing the previous element*
<,./;'{}|
<":;'>
</trainingOrganization>
If you can't find any settings or coding to let do it automaticaly, try it by replacing the characters with a \ in front of it before parsing.
An other possibility is to use xml correctly and not allow the structure to set <> between elements, which is an easiest way i think.
I am using the Cobol XML Parser to parse an xml document that originated from the HFS (USS) file system through batch JCL.
My problem is that the XML Parser is returning "XML DOCUMENT ERROR 0000000317" which seems to be an encoding issue.
Does anyone know how to get past this?
Thanks
You will need to ensure that the encoding tag on the XML declaration is valid and agrees with what the actual document is. You will also need to make sure that the LPAR you are running on has the proper code page conversions defined in Unicode Conversion Services for z/OS.
I have a problem with parsing xml. I'm using NSXMLParser and when xml contains tag with attribute with data including quotation marks, it finishes with errorOccur and makes me very upset. Do you know about some solution,setting for xmlparser or anything where could be the problem?
Example:
<stuff attr="This is "special" text."/> ---> PROBLEM
<stuff attr="This is some text."/> ---> THIS IS OK
Thank you
The "problem" XML is not correctly formed, and as such the parser is correct in generating an error - even at the expense of making you very upset :-) Parsers are like that.
As mentioned by #D33 in the comment, the XML should use " - so if you have written the code producing the XML yourself, you can fix it there. Otherwise, you'd have to re-write the malformed XML into correct XML, and that is a slippery slope.
I am using libxml for parsing the xml. I have referred the XMLPerformance example by apple.
Following is the part of xml document which is causing a problem as it contain the " " string. i cannot just replace this " " with any other string is i am getting data in didReceiveData delegate method and i am parsing that data.
Is there any solution to resolve this issue which is coming because of special character?
<ParentTag>
<AUTHOR>Actavis"Totowa "LLC</AUTHOR>
<SPL_INACTIVE_ING>lactose"monohydrate"/"magnesium"stearate"/"starch"pregelatinized"/"talc</SPL_INACTIVE_ING>
</ParentTag>
Any help will be appreciated.
Thanks in advance
To make sure your XML is well format, you can test you XML first with any online XML validator and then later you should parse that.
I am writing an iPhone app that has to pull raw HTML data off a website an grab the url of the links and the displayed text of a link.
For example in the like Click here to go to google
It would pull grab
url = www.google.com
text = Click Here to go to google
I'm using the regexlite library but i'm in no way an expert on regular expressions i have tried several things to get this working.
I want to use the following code
NSString *searchString = #"$10.23, $1024.42, $3099";
NSString *regexString = #"\\$((\\d+)(?:\\.(\\d+)|\\.?))";
NSArray *capturesArray = NULL;
capturesArray = [searchString arrayOfCaptureComponentsMatchedByRegex:regexString];
So my question is can someone tell me what the searchString would be to parse html links or point me to a clear tutorial on how regexlite works i have tired reading the documentation at http://regexkit.sourceforge.net/RegexKitLite/ and i dont understand it.
Thanks in advance,
Zen_silence
In short, don't do that. Regular expressions are a horrible way to parse HTML. HTML documents are highly structured with a hierarchy of tags whose contents may span lines without said lines appearing in the rendered form.
Assuming well structured HTML, you can use an XML parser.
In particular, the iPhone offers the NSXMLParser and some good examples of usage therein.
searchString would be the whole raw HTML text, and regexString should be more like:
NSString *regexString = #"href=\"(.*)\">(.*)<";
Then you would use capturing matches to pull out match1 and match2, repeating the match through the HTML text using the Range option for searching so that you would skip past what you had already searched...
I don't know what you are trying to do with searchString and the numbers though.
In case anyone else has this same question the regex string to match an html link is
NSString *regexString = #"<a href=([^>]*)>([^>]*) - ";
The Oreilly book "Mastering Regular Expressions" helped me figure this out really quickly i highly recommend reading if you are trying to use regular expressions.