XML Parsing issue with special characters - iphone

I am trying to display “Administrative File & Express” but it is displaying as "Express". So I am unable to show anything that is before the “&”.

You need to escape chars like '&' in XML Parsing. See following link...
http://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references
What characters do I need to escape in XML documents?
Now check XML you are receiving. if you are not receiving chars with escape sequence then you need to handle it in your code.....
Write here if you need further details.....

Related

How to encode text when generating an xml file using rythm

I have to encode text in an error message tag while generating an xml file. My tag is
"ErrorMessage" any text with special character suchs as <>#$%^& "/ErrorMessage". Is there a way to encode those special characters when generating file using rythm template engine?
They should be escaped automatically unless you use .raw() extension. If some chars are not escaped properly please submit an issue on github

escape character & stopping parsing

I am trying to parse some data using nsxmlparser, whenever there is a &(ampersand) present in the text being received it just stops reading the parsed data. How can I read & normally, similar to other normal characters.
Thanks
Pankaj
A lone ampersand in an XML document is not valid except in a CDATA section. You can either have your XML provider provide valid XML by either:
Using the & character entity where you want ampersands.
Putting text containing ampersands into a CDATA section.
Could not find the solution so i had to replace the & with some characters in backend and then again replace it in iphone while using it

Character '&' in XML Parsing iphone

I am using NSXMLParsing to parse an XML , whose formatting is not in my control
From XML it seems it's using UTF-8 encoding, however i get illegal character encoding error when a character like '&' comes into picture.
Due to this i have to go the dirty way of breaking strings and parsing.
Any way out?
Suggestions ?
Thanks
Yogurt
It sounds like you have malformed XML. "&" is the start of an entity in XML, e.g. & or <. Having a raw "&" by itself that doesn't match an entity is illegal.

query about xml parsing

i just want to knw,is there any boundations in xml parsing with characters
like can we parse a word containing some characters like
"frühe" containing "ü"
"böser" containing "ö"
while i am parsing my xml,which is few different languages, some characters are like the above.
and wen i saw in console, it get interpted,exaactly wen it reacher "ü"
becoz at console it prints "fr"
so can someone provide me some ideas about this thing
regards
shishir
If you are using the standard NSXmlParser class and the XML file has the correct encoding= attribute then you shouldn't have anything to worry about. The console output probably isn't unicode-aware so it is interpreting the multi-byte UTF-8 characters literally. Try showing the parsed text in a UIAlertView or some other UI element and see if you still have problems.

json parsing in objective c

while parsing the content of a .json file, string like "jamie's" is represented as "jamie 's".Any one know why it is so?
Make sure you are using application/json as a content type to transfer the data from the server to the client.
You can also go through following link
http://mobile.tutsplus.com/tutorials/iphone/iphone-json-twitter-api/
because the apostrophe is a special charachter and cant be transmitted inside of http packets. all special characters must be replaced with escape sequences like ' or with percent escapes %27 ...
in the NSString class you will find the methods 'stringByReplacingPercentEscapesUsingEncoding:' and 'stringByAddingPercentEscapesUsingEncoding:' for handle percent escapes.
the escape sequencies you must handle by yourself for example with 'stringByReplacingOccurrencesOfString:#"##039;" withString:#"'"' ...