У меня есть следующий фрагмент кода:
var settings = new XmlReaderSettings();
settings.DtdProcessing = DtdProcessing.Ignore;
reader = XmlReader.Create(url, settings);
try
{
doc.Load(reader); // Error here
}
catch(Exception ex)
{
}
где URL:
http://localhost.:38734/mysubdir/data.xml
Но я получаю ошибку:
System.Xml.XmlException: Reference to undeclared entity 'nbsp'. Line 111, position 20.
at System.Xml.XmlTextReaderImpl.Throw(Exception e)
at System.Xml.XmlTextReaderImpl.HandleGeneralEntityReference(String name, Boolean isInAttributeValue, Boolean pushFakeEntityIfNullResolver, Int32 entityStartLinePos)
at System.Xml.XmlTextReaderImpl.HandleEntityReference(Boolean isInAttributeValue, EntityExpandType expandType, Int32& charRefEndPos)
at System.Xml.XmlTextReaderImpl.ParseText(Int32& startPos, Int32& endPos, Int32& outOrChars)
at System.Xml.XmlTextReaderImpl.ParseText()
at System.Xml.XmlTextReaderImpl.ParseElementContent()
at System.Xml.XmlTextReaderImpl.Read()
at System.Xml.XmlLoader.LoadNode(Boolean skipOverWhitespace)
at System.Xml.XmlLoader.LoadDocSequence(XmlDocument parentDoc)
at System.Xml.XmlLoader.Load(XmlDocument doc, XmlReader reader, Boolean preserveWhitespace)
at System.Xml.XmlDocument.Load(XmlReader reader)
at EnviroTracker.Feed.FeedReader.Get(String url, String username, String password) in c:\FeedReader.cs:line
<?xml version="1.0" encoding="UTF-8"?>
<server host="IPC_Server_Room" address="10.10.50.22" name="RSM" owl-version="CB_705" product-version="3.5.0" pversion="2.00" mac-address="00:19:85:E0:20:DF" datetime="Tue, 03/01/11 23:53:01" company="Geist Manufacturing" company-url="http://www.abc.com" support-email="support@geistmfg.com" support-phone="800.432.3219" console-id="chh" tempunit="F" uptime="238871">
<cameras>
</cameras>
<devices>
<device id="0145B5D613000098" name="IPC_Server_Room" type="GeistGoos" available="1" index="0">
<field key="TempC" value="24.86" niceName="Temperature (C)" min="-40.0" max="123.8" type="0" />
<field key="TempF" value="76.74" niceName="Temperature (F)" min="-40.0" max="254.8" type="2" />
<field key="Humidity" value="32" niceName="Relative Humidity" min="0.0" max="100.0" type="2" />
<field key="DewPtC" value="7.0" niceName="Dew Point (C)" min="-40.0" max="123.8" type="0" />
<field key="DewPtF" value="44.7" niceName="Dew Point (F)" min="-40.0" max="254.8" type="2" />
<field key="Light" value="3" niceName="Light Level" min="1.0" max="100.0" type="2" />
<field key="Airflow" value="23" niceName="Air Flow" min="0.0" max="100.0" type="2" />
<field key="Sound" value="3" niceName="Sound Level" min="0.0" max="99.0" type="2" />
<field key="IO1" value="98" niceName="Power" min="0.0" max="99.0" type="2" />
<field key="IO2" value="97" niceName="Door Contact" min="0.0" max="99.0" type="2" />
<field key="IO3" value="99" niceName="Water Snake" min="0.0" max="99.0" type="2" />
<field key="Volts" value="122.8" niceName="Volts" min="0.0" max="275.0" type="2" />
<field key="Volt-Pk" value="122.9" niceName="Volts (Peak)" min="0.0" max="275.0" type="2" />
</device>
</devices>
<alarms>
</alarms>
</server>
Как я могу это исправить