Click here to Skip to main content
15,916,463 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello. I am new to c#. I am trying to parse elements of a xml file to the text boxes in c#.
can any one help me on how to go for this?

Share this answer
Sergey Alexandrovich Kryukov 5-Sep-13 22:35pm    
That's correct and useful, my 5, but why only this way? There are others which may be beneficial, depending on the task. Please see my answer.
Ron Beyer 5-Sep-13 22:38pm    
The "I'm new to C#" part is why I highlighted this one, XmlDocument and XDocument with Linq are more advanced features, the XmlReader is pretty easy to use. +5'd on yours too for pointing out the other ones.
Sergey Alexandrovich Kryukov 5-Sep-13 22:42pm    
Thank you, Ron.

If you want to take into account little experience, XmlDocument is apparently the easiest. And XmlReader is relatively tricky. I relatively recently created a whole technology using it in implementation (and this is the replacement of Microsoft Data Contract, pretty advanced stuff using Reflection.Emit), so I know how tricky it is. It's only good for best performance.

Ron Beyer 5-Sep-13 22:43pm    
Maybe I use it too much, I find it easier than XmlDocument :)
Sergey Alexandrovich Kryukov 5-Sep-13 22:57pm    
Maybe... :-)
You can use at least three different ways of parsing offered by .NET FCL. Here is my short overview of them:

  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.

Good luck,
Share this answer

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