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
261 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
Comment Utility
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
Comment Utility
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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Suggested Solutions

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
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…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

762 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

12 Experts available now in Live!

Get 1:1 Help Now