I tried to add the xml file to an existing file, everything works fine, but I have a problem with the default namespace when it is added.
This is the code I use to add:
XmlNode newChild = doc.CreateNode(XmlNodeType.Element, "image", ""); newChild.Attributes.Append(doc.CreateAttribute("name", filename)); XmlNode xmlElement = doc.CreateNode(XmlNodeType.Element, "width", null); xmlElement.InnerText = widthValue[1].TrimStart(); newChild.AppendChild(xmlElement);
I get the output as shown below
<image d2p1:name="" xmlns:d2p1="test.jpg"> <width>1024</width> </image>
but I tried to add:
<image name="test.jpg"> <width>1024</width> </image>
source share