【发布时间】:2014-05-15 15:56:17
【问题描述】:
在 C# 中处理 xml 时,我试图在输出中包含空格。这就是我所拥有的
text = text.Replace("<br />", " ");
text = HttpUtility.HtmlDecode(text);
System.Xml.XmlDocument doc = new XmlDocument();
doc.LoadXml(text);
StringBuilder sb = new StringBuilder();
foreach (XmlNode node in doc.DocumentElement.ChildNodes)
{
sb.Append(' ');
sb.AppendLine(node.InnerText);
}
<root><Paragraph>
<![CDATA[ Electrical Technologies]]><br /><![CDATA[Thomas Edison]]> </Paragraph></root>
我希望输出为Electrical TechnologiesSPACEThomas Edison,但输出为Electrical TechnologiesThomas Edison。
任何建议。
谢谢 回复
【问题讨论】:
-
您可能会觉得这很有趣:github.com/jamietre/CsQuery。我觉得用起来更方便。还有
Selecting "div span" from the HTML5 spec (a 6 megabyte HTML file) is about 500 hundred times faster than HtmlAgilityPack
标签: c# xml html-agility-pack