Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Problems reading xml node

Posted on 2013-01-17
3
Medium Priority
?
314 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 1600 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

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…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

721 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