XMLNS namespace preventing me from traversing XML document using VB.net

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
<span style="font-size:10pt; font-family:"Verdana","sans-serif"; color:black Hello,
<span style="font-size:10pt; font-family:"Verdana","sans-serif"; color:black Ive been trying to write a program to modify a Collada file â which is an xml graphics exchange format. The file looks like this, although<span style="font-size:10pt; font-family:"Verdana","sans-serif"; color:black
obviously<span style="font-size:10pt; font-family:"Verdana","sans-serif"; color:black a lot bigger .
<span style="font-size:10pt; font-family:"Verdana","sans-serif"; color:black <br/>

<div style="color:black; background-color:white
<pre><span style="color:blue <?<span style="color:#a31515 xml <span style="color:red version<span style="color:blue =<span style="color:black "<span style="color:blue 1.0<span style="color:black " <span style="color:red encoding<span style="color:blue =<span style="color:black "<span style="color:blue utf-8<span style="color:black "<span style="color:blue ?>
<span style="color:blue <<span style="color:#a31515 COLLADA <span style="color:red xmlns<span style="color:blue =<span style="color:black "<span style="color:blue http://www.collada.org/2005/11/COLLADASchema<span style="color:black " <span style="color:red version<span style="color:blue =<span style="color:black "<span style="color:blue 1.4.0<span style="color:black "<span style="color:blue >
<span style="color:blue <<span style="color:#a31515 library_materials<span style="color:blue >
<span style="color:blue <<span style="color:#a31515 material <span style="color:red id<span style="color:blue =<span style="color:black "<span style="color:blue red<span style="color:black " <span style="color:red name<span style="color:blue =<span style="color:black "<span style="color:blue red<span style="color:black "<span style="color:blue >
<span style="color:blue <<span style="color:#a31515 instance_effect <span style="color:red url<span style="color:blue =<span style="color:black "<span style="color:blue #red-fx<span style="color:black "<span style="color:blue />
<span style="color:blue </<span style="color:#a31515 material<span style="color:blue >
<span style="color:blue </<span style="color:#a31515 library_materials<span style="color:blue >
<span style="color:blue </<span style="color:#a31515 COLLADA<span style="color:blue >
[/code]


<span style="font-size:10pt; font-family:"Verdana","sans-serif"; color:black Im working vb express 2010 and am pretty new to VB. When I started out (working from tutorials), I was unable to get anything working whilst the COLLADA element had the xmlns
namespace, so I removed this from my test file (and the version attribute).
<span style="font-size:10pt; font-family:"Verdana","sans-serif"; color:black What Iâve written is along the lines of:
<span style="font-size:10pt; font-family:"Verdana","sans-serif"; color:black <br/>

<div style="color:black; background-color:white
<pre>XDoc = XElement.Load(<span style="color:#a31515 "c:tempinput_collada.dae ")

<span style="color:blue Dim lib_materials = XDoc.Element(<span style="color:#a31515 "library_materials")

<span style="color:blue For <span style="color:blue Each material <span style="color:blue In lib_materials.Elements(<span style="color:#a31515 "material")
material.AddFirst(<span style="color:blue New XElement(<span style="color:#a31515 "my_element", <span style="color:#a31515 "new stuff"))<br/><span style="color:blue Next

XDoc.Save(<span style="color:#a31515 "c:tempoutput_collada.dae")
[/code]


<span style="font-size:10pt; font-family:"Verdana","sans-serif"; color:black Every works fine with me test file, but Iâve now returned to the issue of the namespace.<span>
Despite trying all sorts of things, I donât understand how it works and what is required to get this working.
<span style="font-size:10pt; font-family:"Verdana","sans-serif"; color:black As it stands, with the namespace in place,
lib_materials is set to nothing!
<span style="font-size:9.5pt; font-family:Consolas
<span style="font-size:10pt; font-family:"Verdana","sans-serif"; color:black Can anybody help me please?
<span style="font-size:10pt; font-family:"Verdana","sans-serif"; color:black Thanks in anticipation.
<span style="font-size:10pt; font-family:"Verdana","sans-serif"; color:black Andrew
<br/>
<br/>

View the full article
 
Back
Top