I am creating an XML file from C # code, but when I add an XML node attribute, I get a problem. Below is the code.
XmlDocument doc = new XmlDocument(); XmlNode docRoot = doc.CreateElement("eConnect"); doc.AppendChild(docRoot); XmlNode eConnectProcessInfo = doc.CreateElement("eConnectProcessInfo"); XmlAttribute xsiNil = doc.CreateAttribute("xsi:nil"); xsiNil.Value = "true"; eConnectProcessInfo.Attributes.Append(xsiNil); docRoot.AppendChild(eConnectProcessInfo);
Result:
<eConnect> <eConnectProcessInfo nil="true"/> </eConnect>
Expected Result:
<eConnect> <eConnectProcessInfo xsi:nil="true"/> </eConnect>
The XML attribute does not add "xsi: nil" to the xml file. Please help me with this, where I am wrong.
source share