I have XHTML file which starts with:
<html xmlns="http://www.w3.org/1999/xhtml">
I load it:
XmlDocument xml = new XmlDocument();
StringReader sr = new StringReader(html);
XmlTextReader xmltr = new XmlTextReader(sr);
xmltr.Namespaces = false;
xml.Load(xmltr);
When I call xml.InnerXml
I always got The 'xmlns' attribute is bound to the reserved namespace 'http://www.w3.org/2000/xmlns/'.
exception and can't access inner xml of my XmlDocument. How to get rid of xmlns during load?
SOLUTION IS:
XmlNode xmln = xml.SelectSingleNode("//html");
if (xmln != null)
((XmlElement)xmln).RemoveAttribute("xmlns");