Hello,
I have a problem with the namespace prefix.
I need to add nodes to a xml file that is not created by me.
It has a namespace with the prefix "NFD".
So an already existing node looks like that:
<NFD:Sonstiger_Hinweis>
<NFD:Erfassungsdatum>20070102</NFD:Erfassungsdatum>
<NFD:Hinweis>Patient leidet an Klaustrophobie</NFD:Hinweis>
</NFD:Sonstiger_Hinweis>
If I try to add a node by myself with the following c# Code excerpt:
XmlNode newHinweis =
myVSDXMLDoc.CreateNode(XmlNodeType.Element,"Sonsti ger_Hinweis", "NFD");
XmlNode newSub1 = myVSDXMLDoc.CreateNode(XmlNodeType.Element,
"Erfassungsdatum", "NFD");
newSub1.InnerText = DateTime.Now.ToString("yyyyMMdd");
newHinweis.AppendChild(newSub1);
XmlNode newSub2 = myVSDXMLDoc.CreateNode(XmlNodeType.Element, "Hinweis",
"NFD);
newSub2.InnerText = "MeinHinweis";
newHinweis.AppendChild(newSub2);
myNodes[0].AppendChild(newHinweis);
I get the following:
<Sonstiger_Hinweis xmlns="NFD">
<Erfassungsdatum>20070809</Erfassungsdatum>
<Hinweis>MeinHinweis</Hinweis>
</Sonstiger_Hinweis>
As you can see, the NFD is not used as a prefix :(
If I try it by leaving the Namespace param empty and placing it in the
node name like this:
XmlNode newHinweis =
myVSDXMLDoc.CreateNode(XmlNodeType.Element,"NFD:So nstiger_Hinweis", "");
It will look like this:
<Sonstiger_Hinweis>
<Erfassungsdatum>20070809</Erfassungsdatum>
<Hinweis>MeinHinweis</Hinweis>
</Sonstiger_Hinweis>
The NFD Prefix is missing then.
So I tried to find a solution using Google, but my limited english
speaking capabilities did not bring me too far :(
Any help is appreciated
Markus Bauer