G
GR
Hi,
I have something like the following:
(Please note this not actual code and it's very rough)
string source = "<abc:Root
xmlns:abc="http://mynamespace.com><abc:Record/></abc:Root>"
XmlDocument doc = new XmlDocument();
doc.LoadXml(source);
I now want to add a node such as the following:
XmlDocument tempDoc = new XmlDocument();
tempDoc.LoadXml("<abc:Order/>");
doc.FirstChild.FirstChild.AppendChild(tempDoc.FirstChild);
But when I do this the "abc:" is stripped out of the xml.
What I'm after is to add a new node to the 'doc' document and for it to
have the "abc:" prefix. I've tried various ways (create nodes, create
document fragment, create xmldoc etc) but all the methods I've tried so
far either strip the "abc:", crash or include the "abc:" but also with
the entire namespaceuri (which I dont want either).
So I have the following:
"<abc:Root xmlns:abc="http://mynamespace.com><abc:Record/></abc:Root>"
Now using C# I want to add a new node so that the doc.OuterXml looks
like the following:
"<abc:Root
xmlns:abc="http://mynamespace.com><abc:Record><abc:Order/></abc:Record></abc:Root>"
If possible please post a full code snippet.
Thanks
I have something like the following:
(Please note this not actual code and it's very rough)
string source = "<abc:Root
xmlns:abc="http://mynamespace.com><abc:Record/></abc:Root>"
XmlDocument doc = new XmlDocument();
doc.LoadXml(source);
I now want to add a node such as the following:
XmlDocument tempDoc = new XmlDocument();
tempDoc.LoadXml("<abc:Order/>");
doc.FirstChild.FirstChild.AppendChild(tempDoc.FirstChild);
But when I do this the "abc:" is stripped out of the xml.
What I'm after is to add a new node to the 'doc' document and for it to
have the "abc:" prefix. I've tried various ways (create nodes, create
document fragment, create xmldoc etc) but all the methods I've tried so
far either strip the "abc:", crash or include the "abc:" but also with
the entire namespaceuri (which I dont want either).
So I have the following:
"<abc:Root xmlns:abc="http://mynamespace.com><abc:Record/></abc:Root>"
Now using C# I want to add a new node so that the doc.OuterXml looks
like the following:
"<abc:Root
xmlns:abc="http://mynamespace.com><abc:Record><abc:Order/></abc:Record></abc:Root>"
If possible please post a full code snippet.
Thanks