我正在尝试从以下文件中读取XML:
var XmlData = XElement.Load(@"D:\test.xml");
test.xml
引用另一个xml文件,如:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE document [ <!ENTITY systems SYSTEM 'file:D:\systems.xml'> ]>
<Root>
&systems;
<Servers>
<Server>Server1</Server>
<Server>Server2</Server>
</Servers>
</Root>
systems.xml
<Systems>
<System Id="1" Name="System1" />
<System Id="2" Name="System2" />
</Systems>
然而,我在XmlData
取回的是
<Root>
<Servers>
<Server>Server1</Server>
<Server>Server2</Server>
</Servers>
</Root>
如何在阅读systems.xml
test.xml
的内容
答案 0 :(得分:1)
尝试这样的事情:
XmlReaderSettings settings = new XmlReaderSettings();
settings.DtdProcessing = DtdProcessing.Parse;
XmlReader reader = XmlReader.Create("test.xml", settings);
var XmlData = XElement.Load(reader);