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
265 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 500 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

737 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