Solved

Problems reading xml node

Posted on 2013-01-17
3
308 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
  • 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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

895 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

14 Experts available now in Live!

Get 1:1 Help Now