VB 9.0 Xml features - Xml namespaces example

Bill McCarthy asked me to post Xml axis members example using namespaces. So I updated the sample from my previous post as follows:

 

I added an imports statement for Xml namespace:

Imports ns = "https://someNamespace"

 

I also update my xml document to include namespaces:

Dim Person = _

<ns:Person ns:Dept="SQL Server" xmlns:ns="https://someNamespace">

            <ns:Name>Erik Meijer</ns:Name>

</ns:Person>

 

Finally, I updated the code that uses the new syntax for Xml axis members:

      Console.WriteLine(Person.<ns:Name>.Value)

      Console.WriteLine(Person.@ns:Dept.Value)

      Person.<ns:Name>.Value = "Mike Champion"

      Console.WriteLine(Person.<ns:Name>.Value)

 

This code produces the following output:

Erik Meijer

SQL Server

Mike Champion

 

 

Avner Aharoni