Groups | Blog | Home
all groups > dotnet xml > february 2007 >

dotnet xml : vb.net xml namespace xmlns xmldocument


marfi95
2/21/2007 12:16:34 PM
I am using XMLDocument to create my xml. How do I remove the
namespace information ? It is being put on all my xml nodes:

<MyServ xmlns="http://www....../XInclude>
<Timeout xmlns="">100</Timeout
<MyServ>

I am using CreateElement as such

xElem = newXMLConfigDoc.CreateElement("Timeout")
xElem.InnerText = "100"
rootNode.AppendChild(xElem)

What am I doing wrong ??
Martin Honnen
2/22/2007 2:23:36 PM
[quoted text, click to view]

Const XiNs As String = "http://www.w3.org/2000/xmlns/"
Dim XmlDoc As XmlDocument = New XmlDocument
XmlDoc.AppendChild(XmlDoc.CreateElement("MyService"))
Dim XiAttribute As XmlAttribute =
XmlDoc.CreateAttribute("xmlns", "xi", XiNs)
XiAttribute.Value = "http://www.w3.org/2003/XInclude"
XmlDoc.DocumentElement.SetAttributeNode(XiAttribute)
Dim Timeout As XmlElement = XmlDoc.CreateElement("Timeout")
Timeout.InnerText = "100"
XmlDoc.DocumentElement.AppendChild(Timeout)

--

Martin Honnen --- MVP XML
AddThis Social Bookmark Button