C#XML格式化为文本显示XML字符串中的所有HTML

C#XML格式化为文本显示XML字符串中的所有HTML,c#,html,xml,C#,Html,Xml,我几乎从未用C#写过任何东西,这是我第一次尝试。我的一切工作都很顺利,可以将XML显示为漂亮的打印XML。我遇到的一个问题是,在XML之后发布的HTML在XML内部复制和附加自身。我真的很困惑 C#将字符串显示为XML: XmlDocument doc = new XmlDocument(); doc.Load(filepath + filename + ".xml"); string xmlcontents = doc.InnerXml; string xmlOut = System.Xml.

我几乎从未用C#写过任何东西,这是我第一次尝试。我的一切工作都很顺利,可以将XML显示为漂亮的打印XML。我遇到的一个问题是,在XML之后发布的HTML在XML内部复制和附加自身。我真的很困惑

C#将字符串显示为XML:

XmlDocument doc = new XmlDocument();
doc.Load(filepath + filename + ".xml");
string xmlcontents = doc.InnerXml;
string xmlOut = System.Xml.Linq.XDocument.Parse(xmlcontents).ToString();

this.statusLabel.Text = "<XMP>" + xmlOut + "<\\XMP>";
XmlDocument doc=新的XmlDocument();
doc.Load(文件路径+文件名+“.xml”);
字符串xmlcontents=doc.InnerXml;
字符串xmlOut=System.Xml.Linq.XDocument.Parse(xmlcontents.ToString();
this.statusLabel.Text=“+xmlOut+”;
正在显示的内容:


我是哑巴\应该是/。从我的错误中学习

更改为:

this.statusLabel.Text = "<XMP>" + xmlOut + "<\\XMP>";
this.statusLabel.Text=“+xmlOut+”;
致:

this.statusLabel.Text=“+xmlOut+”;
this.statusLabel.Text = "<XMP>" + xmlOut + "</XMP>";