Solved

Problems reading xml node

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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

760 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

17 Experts available now in Live!

Get 1:1 Help Now