Entity resolution..Custom XmlResolver

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
Hi, Im having problems with entities and LoadXml:

XmlException: Reference to undeclared entity nbsp. Line 1, position 5.

Code:

<div style="text-align:left
<div class=codeseg>
<div class=codecontent>
<div class=codesniptitle><span style="width:100% Code Block
    class Program
    {
        static void Main(string[] args)
        {
            string xml = "<r>&nbsp;</r>";
            XmlDocument doc = new XmlDocument();
            doc.LoadXml(xml);
        }
    }

Adding the following does not solve it:

<div style="text-align:left
<div class=codeseg>
<div class=codecontent>
<div class=codesniptitle><span style="width:100% Code Block
doc.XmlResolver = null;

Ive also tried using a StringReader and passing that in to an XmlReader and same issue. Ive also tried creating my own XmlResolver, but it never gets called, even if I set it on the XmlReader. Ive also tried creating my own XmlReader and overriding CanResolveEntity to return false, but that does not work.

Ive run out of ideas, anyone know why this is occuring?

Thanks!
Kevin



View the full article
 
Back
Top