We help IT Professionals succeed at work.

read value from xmlnode returned by asp.net web service

dobbinjp
dobbinjp asked
on
638 Views
Last Modified: 2012-06-21
I have developed a web service that accepts an input code and returns data as an XMLnode. The format of the returned XMLnode is attached. I can read the entire returned xmlnode and bind it to a gridview with my attached code. However, I need to be able to read the individual values and my code doesn't seem to work where I am trying to display one particular value as a label (I get null reference exceptions). The web service is located at the following location:

http://transp2.vuse.vanderbilt.edu/webservices/service.asmx

The service is "getprevandnext" and to use it pass a value of "19I0065001" to see what is returned.

If there is a better way to read this data than my current code, please advise.

Thanks for your help!!
'returned data format below
 
<Data>
<PreviousID>94I0065001</PreviousID>
<NextID>83I0065001</NextID>
<LogMile>22.17</LogMile>
</Data>
 
'here is my code, everything works except where noted (Label 4 text)
 
        Dim consumewebservice As New edu.vanderbilt.vuse.transp2.Service
 
        Dim reader As XmlNodeReader
        Dim ds As New DataSet()
        Dim wsNode As XmlNode
 
        wsNode = consumewebservice.GetPrevandNext("19I0065001")
        'the following line does not work
        Label4.Text = wsNode.Attributes("PreviousID").Value.ToString
        
        reader = New XmlNodeReader(wsNode)
 
        ds.ReadXml(reader)
 
        GridView1.DataSource = ds.Tables("Data")
        GridView1.DataBind()
        GridView1.AutoGenerateColumns = True

Open in new window

Comment
Watch Question

CERTIFIED EXPERT
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION

Author

Commented:
thanks for the quick solution, it worked perfectly!!!!
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.