Solved

Problems reading xml node

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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

809 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