Thursday, December 24, 2009

NSXMLParser : Nuggets

I was trying to parse an xml of the form between the tags: text xml1 & text xml

NSXMLParser was for some reason was considering & as a delimiter and was calling - (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string thrice, once for text xml1, second time for & and third time for text xml2.

Using escape sequence%26 instead of & solved the solved the problem.

Ergo use escape sequence wherever possible instead of &, if parsing with NSXMLParser. I do think there is such problem with xerces and tinyxml.

Below are some commonly used escape sequences:
CharacterEscape Code
SPACE%20
<%3C
>%3E
#%23
%%25
{%7B
}%7D
|%7C
\%5C
^%5E
~%7E
CharacterEscape Code
[%5B
]%5D
`%60
;%3B
/%2F
?%3F
:%3A
@%40
=%3D
&%26
$%24

No comments:

Post a Comment

LinkWithin

Related Posts with Thumbnails