I Need to Code an XML-File in C# using XMLDocument. I extract the desired XML-File and only Need to insert some Elements i Need to add.
The EXPECTED Output should look like this:
<service>
<coding>
<system value="https://somethingichanged" />
<code value="myvalue" />
</coding>
</service>
However, my Output Looks like this:
<service>
<coding>
<system>https://somethingichanged</system>
<code>myvalue</code>
</coding>
</service>
Here is my Code:
string[] tag = new string[] { "service", "coding", "system", "code", "http://URI"};
XmlElement Service = m_XMLDoc.CreateElement(tag[0], tag[4]);
XmlElement Coding = m_XMLDoc.CreateElement(tag[1], tag[4]);
Service.AppendChild(Coding);
//Fill Element
XmlNode System = m_XMLDoc.CreateNode(XmlNodeType.Element, tag[2], tag[4]);
XmlNode Code = m_XMLDoc.CreateNode(XmlNodeType.Element, tag[3], tag[4]);
System.InnerText = "https://somethingichanged";
Coding.AppendChild(System);
Code.InnerText = myTSS[i].ToString();
Coding.AppendChild(Code);
How does the correct Code look like? Thanks!