NSXMLParser quotation in attribute text - iphone

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.

Related

TBXML Parser with Special character getting EXC_BAD_ACCESS

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.

Parsing USS XML file in Cobol?

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.

Libxml parser iphone issue

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 "&nbsp" string. i cannot just replace this "&nbsp" 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.

NSXMLParser & Problem

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.

xmlCtxtGetLastError - Iphone

I have been programming with NSXMLParser for quite a while and lately, I came out with this error. The strangiest thing is that it only happens in debug mode. Once I load the App in Simulator and run it from Simulator (without Xcode involved), it runs fine.
The code is very straight foward, it is a simple XML parsing whose contents were loaded from the web in a separated thread.
Does anybody have alredy encoutered that error??
Thanks in advance.
EDIT:
In time I realized that this error occur when you have a bad formated XML Document. In my case, I was extracting some of the contents of an HTML Page and parsing the resulting string, but this string was not allways well formed. A little modification an voilá...
Ensure that your documents are well formed when parsing or you may have the same mistake...
PS: The parser error method did not catch this error.
In time I realized that this error occur when you have a bad formated XML Document. In my case, I was extracting some of the contents of an HTML Page and parsing the resulting string, but this string was not allways well formed. A little modification an voilá...
Ensure that your documents are well formed when parsing or you may have the same mistake... PS: The parser error method did not catch this error.