views:

87

answers:

1

I am currently working on program that must read data from a XML stream that some time may contains '&' symbols

i.e :

<XMLRoot>
    <Element>
        <Node>
            This is a dummy data&more!
        </Node>
    </Element>
</XMLRoot>

When I parse this text I get an error message telling me 'reference to undeclare entity'.

Is there a way to remove 'entity check' with the C#'s XMLParser?

+4  A: 

I believe the problem is the XML you posted is a malformed XML, "&" is a reserved character in XML and it needs to be escaped or enclosed in a CDATA section:

<XMLRoot>
<Element>
    <Node>
        This is a dummy data&amp;more!
    </Node>
</Element>
</XMLRoot>

Or:

<XMLRoot>
<Element>
    <Node>
        <![CDATA[ This is a dummy data&more! ]]>
    </Node>
</Element>
</XMLRoot>
Badaro