Solved

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

Posted on 2003-10-29
2
346 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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It seems a simple enough task, yet I see repeated questions asking how to do it: how to pass data between two forms. In this article, I will show you the different mechanisms available for you to do just that. This article is directed towards the .N…
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:…
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

910 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

21 Experts available now in Live!

Get 1:1 Help Now