简体   繁体   English

xml C#中的无效字符

[英]invalid characters in xml c#

I am trying to parse the below with in C# with xmldocument. 我试图用xmldocument在C#中解析以下内容。 but I can't load it. 但我无法加载。 It says invalid characters. 它说无效字符。 Even in the browser it doesn't display correctly complaining about invalid characters. 即使在浏览器中,它也无法正确显示有关无效字符的信息。 I need to loop through all elements in this string. 我需要遍历此字符串中的所有元素。 Can someone please advise what's wrong here? 有人可以告诉我这是怎么回事吗?

<div><b>Q1.
What is your name?:</b> BTB (Build the bank)</div>
<div><b>Q2.
How old are you?:</b> 29</div>

code is this: 代码是这样的:

        XmlDocument xml = new XmlDocument();
        xml.Load(item.Summary);

error is: "Illegal characters in path." 错误是:“路径中包含非法字符。”

XmlDocument.Load expects a file name to load the xml from. XmlDocument.Load期望从中加载xml的文件名。 Try LoadXml . 尝试LoadXml

"BTB (Build the bank)" needs to be wrapped in its own tag if this shall be a valid xml. 如果“ BTB(建立银行)”应为有效的xml,则必须用其自己的标签包裹。 It is valid html though. 它是有效的html。 Also, xml must have a single top node. 另外,xml必须具有单个顶部节点。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM