?
Solved

Help with idedtifying last element in xml file and obtaining total number of records in an xml file

Posted on 2012-04-08
2
Medium Priority
?
267 Views
Last Modified: 2012-04-30
I am using the cide below to check for a value in an xml file and would like to exit the loop if no match found and the last Receiver_ID element is checked, how do I modify my code to include the syntax for the last Receiver_ID element in my xml file? Or is there a way to obtain the totatal number of Receiver_ID in my file and use the count in my code, for example if count = 10 and Link_ID <> ""?

For Each xnLink As Xml.XmlNode In xdLink.SelectNodes("/Root/LinkA[Receiver_ID='" & C1Receiver.SelectedItem.Value & "']")
            Link_ID = xnLink.SelectSingleNode("LinkAID").InnerText
            If (positioned in Last Receiver_ID) and Link_ID <> ""
                Exit For
            End If
        Next

Thanks,
Victor
0
Comment
Question by:vcharles
[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
2 Comments
 
LVL 12

Expert Comment

by:Alfredo Luis Torres Serrano
ID: 37821516
Have you tried

XmlTextReader reader = new XmlTextReader(sFileName);

http://msdn.microsoft.com/en-us/library/system.xml.xmltextreader_members%28v=vs.80%29.aspx

hope this helps
0
 
LVL 20

Accepted Solution

by:
BuggyCoder earned 2000 total points
ID: 37821542
i would rather suggest against using this approach, try to go for LINQ to XML.
Its much simpler and easy to use, here goes some examples:-

http://msdn.microsoft.com/en-us/vstudio/bb688087
http://msdn.microsoft.com/en-us/vstudio/bb688088
http://www.codeproject.com/Articles/24376/LINQ-to-XML
0

Featured Post

Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

Question has a verified solution.

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

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
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…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
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

777 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