Hi
I'm trying to writ to an existing xml document, but I have a lite problem:
Why does this code add 'xmlns = ""' to the added xml code?? and how does I get rid of it??
The XML file:
-----------------------------------------------------------
<root xmlns=" <Node ID="001">
<Value1>3</Value1>
<Value2>true</Value2>
</Node>
<!-- here coms the inserted xml code --!>
<Node ID="002" xmlns="">
<Value1>9</Value1>
<Value2>false</Value2>
</Node>
</root>
------------------------------------------------------------
The C# code:
------------------------------------------------------------
XmlNode currNode;
XmlDocument doc = new XmlDocument();
doc.Load(reader);
XmlDocumentFragment docFrag = doc.CreateDocumentFragment();
docFrag.InnerXml =
"<Node ID='002'>"+
"<Value1>"+"9"+"</Value1>"+
"<Value2>"+"false"+"</Value2>"+
"</Node>"
currNode = doc.DocumentElement;
currNode.AppendChild(docFrag);
reader.Close();
doc.Save("XMLtest.xml"
------------------------------------------------------------
I'm trying to writ to an existing xml document, but I have a lite problem:
Why does this code add 'xmlns = ""' to the added xml code?? and how does I get rid of it??
The XML file:
-----------------------------------------------------------
<root xmlns=" <Node ID="001">
<Value1>3</Value1>
<Value2>true</Value2>
</Node>
<!-- here coms the inserted xml code --!>
<Node ID="002" xmlns="">
<Value1>9</Value1>
<Value2>false</Value2>
</Node>
</root>
------------------------------------------------------------
The C# code:
------------------------------------------------------------
XmlNode currNode;
XmlDocument doc = new XmlDocument();
doc.Load(reader);
XmlDocumentFragment docFrag = doc.CreateDocumentFragment();
docFrag.InnerXml =
"<Node ID='002'>"+
"<Value1>"+"9"+"</Value1>"+
"<Value2>"+"false"+"</Value2>"+
"</Node>"
currNode = doc.DocumentElement;
currNode.AppendChild(docFrag);
reader.Close();
doc.Save("XMLtest.xml"
------------------------------------------------------------