Eric
Eric

Reputation: 295

invalid characters in xml c#

I am trying to parse the below with in C# with xmldocument. 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."

Upvotes: 0

Views: 458

Answers (2)

Mattias &#197;slund
Mattias &#197;slund

Reputation: 3907

"BTB (Build the bank)" needs to be wrapped in its own tag if this shall be a valid xml. It is valid html though. Also, xml must have a single top node.

Upvotes: 1

Andrew Kennan
Andrew Kennan

Reputation: 14157

XmlDocument.Load expects a file name to load the xml from. Try LoadXml.

Upvotes: 2

Related Questions