moyoteg
moyoteg

Reputation: 347

string is partially parsed when symbol "&" is present

If I have a string like "Fuel & Additives" when my XML parser goes through it ignores anything BEFORE the "&" symbol, why?

    if ([elementname isEqualToString:@"GLDesc"]) 
{
   currentParsedObjectContainer.GLDesc = currentNodeContent;
       NSLog(@"%@",currentParsedObjectContainer.GLDesc);
}

Upvotes: 1

Views: 119

Answers (2)

csano
csano

Reputation: 13696

The ampersand character (&) and the left angle bracket (<) may appear in their literal form only when used as markup delimiters, or within a comment, a processing instruction, or a CDATA section. If they are needed elsewhere, they must be escaped using either numeric character references or the strings "&" and "<" respectively.

http://www.w3.org/TR/2000/REC-xml-20001006#syntax

As the above snippet states, you'll need to escape & to the string &amp; before passing it to the XML parser.

Upvotes: 7

MGZero
MGZero

Reputation: 5963

I'm going to say it has something to do with character codes (for example &lt). I'm not really familiar with xml though, so I'm not sure. Try &amp?

Upvotes: -1

Related Questions