Solved

Problems reading xml node

Posted on 2013-01-17
3
313 Views
Last Modified: 2013-01-17
I have a particular node that I'm trying to get to in the attached file.

I'm trying to use this code:

 refPlanNodeList = xmlDemo.SelectNodes("PPMDResults/Results/patientlist/patient/refplanlist")
                For Each refPlanNode In refPlanNodeList
                    refProv = refPlanNode.SelectSingleNode("refplan").Attributes("refprov").Value
                    If refProv.Replace("rprov", "") = physid Then
                        result = refPlanNode.SelectSingleNode("refplan/id").InnerText
                    End If
                Next

I'm trying to loop through each refplan node but the above doesn't seem to work.
Demo.xml
0
Comment
Question by:rutledgj
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
3 Comments
 
LVL 35

Expert Comment

by:YZlat
ID: 38788067
try this instead:

refPlanNodeList = xmlDemo.SelectNodes("PPMDResults/Results/patientlist/patient/refplanlist/refplan")
        For Each refPlanNode In refPlanNodeList
            refProv = refPlanNode.Attributes("refprov").Value
            If refProv.Replace("rprov", "") = physid Then
                result = refPlanNode.SelectSingleNode("refplan/id").InnerText
            End If
        Next

Open in new window

0
 
LVL 35

Expert Comment

by:YZlat
ID: 38788072
instead of looping through refplan nodes you tried looping through refplanlist, and there is only one in your xml
0
 
LVL 35

Accepted Solution

by:
YZlat earned 400 total points
ID: 38788092
disregard post above - i found one more isssue - the way you retrieve id attribute. Use

refPlanNodeList = xmlDemo.SelectNodes("PPMDResults/Results/patientlist/patient/refplanlist/refplan")
        For Each refPlanNode In refPlanNodeList
            refProv = refPlanNode.Attributes("refprov").Value
            If refProv.Replace("rprov", "") = physid Then ''physid Then
                result = refPlanNode.Attributes("id").Value
            End If
        Next

Open in new window

0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

The Client Need Led Us to RSS I recently had an investment company ask me how they might notify their constituents about their newsworthy publications.  Probably you would think "Facebook" or "Twitter" but this is an interesting client.  Their cons…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

623 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