Click here to Skip to main content
15,949,741 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?
Posted

 
Share this answer
 
v2
Comments
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.
—SA
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.

—SA
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... :-)
—SA
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.
    See http://msdn.microsoft.com/en-us/library/system.xml.xmldocument.aspx[^].
  2. Use the class System.Xml.XmlTextReader; this is the fastest way of reading, especially is you need to skip some data.
    See http://msdn.microsoft.com/en-us/library/system.xml.xmlreader.aspx[^].
  3. Use the class System.Xml.Linq.XDocument; this is the most adequate way similar to that of XmlDocument, supporting LINQ to XML Programming.
    See http://msdn.microsoft.com/en-us/library/system.xml.xmldocument.aspx[^], http://msdn.microsoft.com/en-us/library/bb387063.aspx[^].


Good luck,
—SA
 
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