jefftoaster
Programmer
This simple chunk of code:
XmlDocument doc = new XmlDocument();
XmlNode node;
node = doc.CreateElement("requestMessage","urn:test:test2");
doc.AppendChild(node);
node = doc.CreateElement("merchantID");
node.InnerText = "midgoeshere";
doc.DocumentElement.AppendChild(node);
XmlTextWriter tw = new XmlTextWriter("tester.xml", Encoding.ASCII);
tw.Formatting = Formatting.Indented;
doc.Save(tw);
Gives me this:
<?xml version="1.0" encoding="us-ascii"?>
<requestMessage xmlns="urn:test:test2">
<merchantID xmlns="">midgoeshere</merchantID>
</requestMessage>
QUESTION: What's with the xmlns=""? It comes out on every sub-element, and I don't want that. NOTE: I have to create the document this way (otherwise I'd just use xmlwriter to do everything).
XmlDocument doc = new XmlDocument();
XmlNode node;
node = doc.CreateElement("requestMessage","urn:test:test2");
doc.AppendChild(node);
node = doc.CreateElement("merchantID");
node.InnerText = "midgoeshere";
doc.DocumentElement.AppendChild(node);
XmlTextWriter tw = new XmlTextWriter("tester.xml", Encoding.ASCII);
tw.Formatting = Formatting.Indented;
doc.Save(tw);
Gives me this:
<?xml version="1.0" encoding="us-ascii"?>
<requestMessage xmlns="urn:test:test2">
<merchantID xmlns="">midgoeshere</merchantID>
</requestMessage>
QUESTION: What's with the xmlns=""? It comes out on every sub-element, and I don't want that. NOTE: I have to create the document this way (otherwise I'd just use xmlwriter to do everything).