So I have some XML in the following format:
<somenode>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title/>
</head>
<body>
<p>P one</p>
<p>Another p</p>
</body>
</html>
</somenode>
Nestled in there is some html, which I didn't think would be an issue as it would just be treated as xml.
I'm trying to select the contents (InnerXml) of the <body> tag. However, using
xmlDoc.SelectSingleNode("somenode/html/body")
returns null
, and using
xmlDoc.GetElementsByTagName("body")[0].InnerXml
gives the InnerXml - but each <p> has xmlns="http://www.w3.org/1999/xhtml"
appended to it - so the result looks like:
<p xmlns="http://www.w3.org/1999/xhtml">P one</p><p xmlns="http://www.w3.org/1999/xhtml">Another p</p>
Can anyone shed some light on this? Seems like some really weird behavior, any help would be appreciated. I'm only using ASP.net 2.0, so unfortunately trying linq isn't an option.