Solved

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

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Recently while returning home from work my wife (another .NET developer) was murmuring something. On further poking she said that she has been assigned a task where she has to serialize and deserialize objects and she is afraid of serialization. Wha…
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:…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

856 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