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
264 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
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: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

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

Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

821 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