Connecting Tech Pros Worldwide Help | Site Map

[VB.NET][XML] problem of namespace

Newbie
 
Join Date: Jan 2007
Posts: 1
#1: Jan 3 '07
Hello !

I'm creating xml files (.3dxml) by using VB .NET.
I've got a problem with namespaces. I'd like to generate this line :
Expand|Select|Wrap|Line Numbers
  1. <Model_3dxml xmlns="..." xmlns:xsi="..." xsi:schemaLocation="http://www.monURL.com/">
I found two ways to do it.

First method :
Expand|Select|Wrap|Line Numbers
  1. Dim elemRoot As XmlElement
  2. elemRoot = XmlDoc.CreateElement("Model_3dxml")
  3. Dim elemRootAttr As XmlAttribute
  4. elemRootAttr = XmlDoc.CreateAttribute("xsi", "schemaLocation", "http://www.monURL.com/")
  5. elemRoot.Attributes.SetNamedItem(elemRootAttr)
I obtain :
Expand|Select|Wrap|Line Numbers
  1. <Model_3dxml xmlns="..." xmlns:xsi="..." d1p1:schemaLocation="" xmlns:d1p1="http://www.monURL.com"/>
Second Method :
Expand|Select|Wrap|Line Numbers
  1. Dim elemRoot As XmlElement
  2. elemRoot = XmlDoc.CreateElement("Model_3dxml")
  3. Dim elemRootAttr As XmlAttribute
  4. elemRootAttr = xmlDoc.CreateAttribute("xsi:schemaLocation")
  5. elemRootAttr.Value = "http://www.monURL.com"
  6. elemRoot.Attributes.SetNamedItem(elemRootAttr)
I obtain :
Expand|Select|Wrap|Line Numbers
  1. <Model_3dxml xmlns="..." xmlns:xsi="..." schemaLocation="http://www.monURL.com"/>
these two XML files are wrong and I cannot use them...

What is the good way to do ?
Reply