Click here to Skip to main content
15,030,240 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm trying to make a program in VBNET which allows me to parse an xmlfile, then lists all the elements and counts the elements line by line.
My xmlfile looks like this :

<?xml version="1.0" encoding="ISO-8859-1" ?>
- <flexdump>
- <FLXREC1001>
  <PTY002>SIREUS nv</PTY002>
  <PTY004>F. Rooseveltlaan 349</PTY004>
  <PTY022>Support : 9.00 - 12.00</PTY022>
  <PTY025>BE 0437.034.587</PTY025>
  <PTY038>Mijne Heren,</PTY038>
  <PTY061>BE33 8805 3016 3146</PTY061>

Any (simple) ideas ?



It is incredibly simple to do using the XDocument class. Give it a read and check out examples online. This should be a good start.[^]
Sergey Alexandrovich Kryukov 20-Mar-12 14:10pm
This is just one possibility (I voted 4). There are more options; XmlDocument (DOM-based) could be even easier, especially for small XMLs. Please see my answer.
XML parsing is well implemented in .NET. You have at least three different options I overview below:

  1. Use System.Xml.XmlDocument class. It implements DOM interface; this way is the easiest and good enough if the size if the document is not too big.
  2. Use the class System.Xml.XmlTextReader; this is the fastest way of reading, especially is you need to skip some data.
  3. Use the class System.Xml.Linq.XDocument; this is the most adequate way similar to that of XmlDocument, supporting LINQ to XML Programming.


This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900