Hi, I'm having trouble with namespaces when importing nodes. I'd like to get
this output:
<exampleRoot xmlns="http://mynamespace">
<row Lsm_Info="ABC123" />
<row Lsm_Info="DEF456" />
</exampleRoot>
But instead I'm getting:
<exampleRoot xmlns="http://mynamespace">
<row Lsm_Info="ABC123" xmlns="" />
<row Lsm_Info="DEF456" xmlns="" />
</exampleRoot>
This is the code I'm using:
XmlReader reader = command.ExecuteXmlReader();
XmlElement rootNode = xmlDocument.CreateElement("exampleRoot ",
http://mynamespace);
xmlDocument.AppendChild(rootNode);
reader.MoveToContent();
XmlNode readerNode = xmlDocument.ReadNode(reader);
while (readerNode != null)
{
XmlNode importNode = xmlDocument.ImportNode(readerNode, false);
xmlDocument.DocumentElement.AppendChild(importNode );
readerNode = xmlDocument.ReadNode(reader);
}
How do I get rid of the xmlns=""? Any help is much appreciated!
Cheers,
Chris