1

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

D33
  • 239
  • 1
  • 3
  • 14
  • 1
    Use " when the xml is generated. See this post: http://stackoverflow.com/questions/3961505/how-to-escape-double-quotes-in-xml-attributes-values – Rayfleck Dec 30 '11 at 19:36
  • Yes. I would like to. But it's not my xml. Another company provides this service and I'm supposed only to read it and use it. Do you have any idea how to "repair" the pure data (XML in NSDATA) which I download from that server? – D33 Dec 31 '11 at 13:08

1 Answers1

1

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.

Monolo
  • 18,205
  • 17
  • 69
  • 103
  • Thanks for your response. Well, actually parser made me quite confused because he showed me an error with code 65. Which is "spaceIsRequired". But what space, where it is required, whatwhatwhat and I was unable to find out it. Now it makes me a little sense though. Anyway. It's not my xml. I just download it from the server and show the formatted result. And thus it is bad. I just download NSData and give it to NSXMLParser. Is there a way I can repair it? Or it would be as easy as create my own parser? :( Thanks... – D33 Dec 31 '11 at 13:05