我正在尝试反序列化一个 XML 文件,它工作正常,除了包含 HTML 标记的节点。下面是 XML 文件的一个片段:
<article mdate="2011-12-29" key="tr/trier/MI99-02" publtype="informal publication">
<author>Friedemann Leibfritz</author>
<title>A LMI-Based Algorithm for Designing Suboptimal Static H<sub>2</sub>/H<sub>infinity</sub> Output Feedback Controllers</title>
<journal>Universität Trier, Mathematik/Informatik, Forschungsbericht</journal>
<volume>99-02</volume>
<year>1999</year>
</article>
然后,我收到错误:
{"Unexpected node type Element. ReadElementString method can only be called on elements with simple or empty content. Line 1148, position 64."}
错误发生在:
一种基于 LMI 的算法,用于设计次优静态 H 2 /H无穷大输出反馈控制器
HTML 标签 sub 和 /sub 存在的地方。
有没有办法将标题节点作为一个整体反序列化,而忽略 HTML 标签?以下是我的部分代码:
XmlReaderSettings readerSettings = new XmlReaderSettings
{
DtdProcessing = DtdProcessing.Parse,
XmlResolver = new LocalXhtmlXmlResolver()
};
XmlRootAttribute xRoot = new XmlRootAttribute();
xRoot.ElementName = "dblp";
xRoot.IsNullable = true;
XmlSerializer deserializer;
XmlReader textReader;
deserializer = new XmlSerializer(typeof(List<Entity.Article>), xRoot);
textReader = XmlReader.Create(xmlPath, readerSettings);
List<Entity.Article> articleList;
articleList = (List<Entity.Article>)deserializer.Deserialize(textReader);
textReader.Close();
任何帮助将不胜感激 - 谢谢!