Solved

vb.NET + XML ... reader.value isn't returning anything??

Posted on 2003-10-29
2
343 Views
Last Modified: 2008-02-01
I'm trying to read an xml file in vb.net, but I'm having problem reading the value of the elements...

Here's the XML file:

--------- XML Start ---------

<?xml version='1.0'?>
   <VariableList>
      <varItem xmlns="title">This is the Title</varItem>
      <varItem xmlns="terms">These are the terms</varItem>
   </VariableList>

--------- XML End ---------


.... and Here's my vb code:


--------- VB.NET Start ---------

Imports System.XML

Dim textReader As XmlTextReader = New XmlTextReader(strSource$)

        While textReader.Read()
            Dim nType As XmlNodeType = textReader.NodeType

            If nType = XmlNodeType.Element Then
                MsgBox("Element: " & textReader.Name.ToString)
                MsgBox("Space: " & textReader.NamespaceURI.ToString)
                MsgBox("Value: " & textReader.Value.ToString)
            End If
        End While

--------- VB.NET End ---------

My problem is textReader.Value doens't return anything.... I'd like it to msgbox the "This is the Title" & "These are the terms" texts as well as the name and namespaceURI. What am I doing wrong??

Thanks,
- kisk
0
Comment
Question by:kisk
2 Comments
 
LVL 3

Accepted Solution

by:
the-edge earned 100 total points
ID: 9648515
this is the rigth code:

        Dim textReader As XmlTextReader = New XmlTextReader(strSource$)

        While textReader.Read()
            Dim nType As XmlNodeType = textReader.NodeType
            Select Case nType
                Case Xml.XmlNodeType.Element
                    MsgBox("Element: " & textReader.Name.ToString)
                    MsgBox("Space: " & textReader.NamespaceURI.ToString)
                Case Xml.XmlNodeType.Text
                    MsgBox("Value: " & textReader.Value.ToString)
            End Select
        End While


text values are nodes of type Xml.XmlNodeType.Text

the edge
0
 

Author Comment

by:kisk
ID: 9649170
works! Thanks!!

- kisk
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now