I am trying to read inner XML of the root element as string but XmlReader class is namespace aware. Is there any way to ignore the namespaces? I can use any class in BCL as long as it passes the NUNit test below.
[Test]
public void GetInnerXmlTest()
{
string subject = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
"<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\">" +
"<url><loc>abc</loc></url>" +
"<url><loc>def</loc></url>" +
"</urlset>";
XDocument document = XDocument.Parse(subject);
XmlReader xmlReader = document.FirstNode.CreateReader();
xmlReader.MoveToContent();
string innerXml = xmlReader.ReadInnerXml();
//<url xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"><loc>abc</loc></url><url xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"><loc>def</loc></url>
Assert.AreEqual("<url><loc>abc</loc></url><url><loc>def</loc></url>",
innerXml);
}