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
262 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to deploy to IIS 7 on 2008R2 server with DUO 2-step login? 2 37
Error in page 3 46
how to read json value 2 31
Visual Studio 2015 Source Code Control 10 37
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…
As a trusted technology advisor to your customers you are likely getting the daily question of, ‘should I put this in the cloud?’ As customer demands for cloud services increases, companies will see a shift from traditional buying patterns to new…

867 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

16 Experts available now in Live!

Get 1:1 Help Now