3

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 &amp; 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.

EmptyStack
  • 51,274
  • 23
  • 147
  • 178
Rams
  • 1,721
  • 12
  • 22

2 Answers2

3

If you insist on sending invalid XML from your server this should solve it:

[xmlString stringByReplacingOccurrencesOfString:@"&" withString:@"&amp;"]:
// parse xmlString
[categoryName stringByReplacingOccurrencesOfString:@"&amp;" withString:@"&"]:
Erik B
  • 40,889
  • 25
  • 119
  • 135
  • its correct.and one more thing i am trimming whitespace at the end of that string.i am using [string stringByTrimmingCharactersInSet:[NSCharacterSet characterSetWithCharactersInString:@" \n\t"]]; this code will trim middle of the string too. – Rams Jun 03 '11 at 09:46
0

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.

Gypsa
  • 11,230
  • 6
  • 44
  • 82
  • our xml is asp script.we don't have a server access.already our client give an url thats why i am asking any other option – Rams Jun 03 '11 at 09:29