Try this:
newElem = xmlDocument.CreateNode( XmlNodeType.Element, "newnode", nodeList[0].NamespaceURI );
Or show enough details to reproduce the problem.
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hi experts ,
i have a scenario, where i have to read the xml document and create/add an xmlnode to the document.
newElem = xmlDocument.CreateNode("element", "newnode", ""); //creates the node
newElem.InnerText ="test" ;
nodeList[0].AppendChild(newElem); //appends the node
string data = xmlDocument.OuterXml; //while assiging the xmldocument to a string variable , its adding attribute xmlns="" to the newnode added
output:
<newnode xmlns="">test<newnode>
how we can remove the attribute xmlns="" that got added by the xml document?
Note : i have newElem.Attributes.RemoveNamedItem("xmlns="); tried this, this was not helpfull
Try this:
newElem = xmlDocument.CreateNode( XmlNodeType.Element, "newnode", nodeList[0].NamespaceURI );
Or show enough details to reproduce the problem.
Hi There,
Thank you for asking this question on the Microsoft Q&A Platform.
Please check the similar question asked on stackoverflow and this might be helpful for you,
Regards,
Kamlesh Kumar
BizTalk Techie
If this answer solved your problem, please click the Verify Answer button (found below the answer) to help other users who have the same question.