You are here:  » Parsing Ampersands

Support Forum



Parsing Ampersands

Submitted by pintofmilk on Wed, 2008-01-02 17:12 in

MagicParser is not properly parsing this XML

<SearchRequest>
<Where>
<mode>H</mode>
<id>0</id>
<string>Cordial Hotel & Bar City Centre</string>
</Where>
</SearchRequest>

What should I do?

Regards
Ben

Submitted by support on Wed, 2008-01-02 17:18

Hi Ben,

An ampersand on its own within an XML document is not valid XML; as the ampersand character has a special meaning. It is used to define entities that enable you to include characters that themselves have a special meaning within XML. For example, the "less than" sign must be encoded as &lt;. Similarly, the ampersand itself must be encoded as &amp;.

In order to fix this, you will need to contact the person responsible for generating this XML and ask them to make sure that all necessary characters are correctly entity encoded, or properly escaped within a CDATA section. For example, instead of entity encoding the ampersand in your XML sample, the string element could be defined as CDATA as follows:

 <string><![CDATA[Cordial Hotel & Bar City Centre]]></string>

Hope this helps!
Cheers,
David.