Help reading XML using .NET

I want to read in all elements from an XML file.  Currently I'm using XmlTextReader, and I loop through all the elements.  However, XmlTextReader does not seem to give me a way to "look ahead" at other elements.   What I mean by this is, once I find a certain element based on it value, I want to extract data from the next element or the next two elements.   All elements that I need to process are at the same level in the hierarchy.

I could just read all the element data into my own local list of strings, but I thought maybe there was something else I could do.
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Miguel OzSoftware EngineerCommented:
Correct, it only allows you to read an element at the time.
If your file is not too big and memory is not a concern, then you can load all elements into memory using:
var data As XElement = XElement.Load("c:\yourxmlpath.xml")

Open in new window

then you can get all elements or just the element name using the code below.
Dim allElements As IEnumerable(Of XElement) = data.Descendants()
Dim allElementNames As IEnumerable(Of XElement) = data.Descendants("name")

Open in new window

P.S. If more help need please post xml sample.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
HLRosenbergerAuthor Commented:
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.