Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# XML
Anyone have a link for: How to work with XML in C#? Thanks!
Posted 3-Feb-13 12:42pm
Comments
PIEBALDconsult at 3-Feb-13 18:27pm
   
What are you trying to do?
 
In the maen time, read up on XmlDocument
http://msdn.microsoft.com/en-us/library/system.xml.xmldocument.aspx
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Check this link out.
 
C# and XML Source Code Documentation[^]
  Permalink  
Comments
Nemanja Petrovic at 5-Feb-13 14:48pm
   
Thanks!
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

First of all you should have a look at MSDN:
LINQ to XML[^]
You will probably also like to have a look at:
Understanding C#: Simple LINQ to XML[^]
LINQ to XML[^]
 
If you're going to work with really large xml files, there is a SAX implementation available at: SAX for .NET[^]
 

Best regards
Espen Harlinn
  Permalink  
v2
Comments
Sergey Alexandrovich Kryukov at 3-Feb-13 19:06pm
   
Nice links, a 5.
Maybe I gave a just bit more comprehensive answer, please see... :-)
—SA
Espen Harlinn at 3-Feb-13 19:08pm
   
>> please see...
I certainly did :-D
Nemanja Petrovic at 5-Feb-13 14:47pm
   
Thanks!
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

There are different XML libraries in .NET. Here is a short overview:
 
  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 classes System.Xml.XmlTextWriter and 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.xmlwriter.aspx[^], 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[^].
 
Note that in many cases you don't need to work with XML directly. It can be done for you if you are using serialization. Please see:
http://en.wikipedia.org/wiki/Serialization#.NET_Framework[^],
http://msdn.microsoft.com/en-us/library/vstudio/aa349369%28v=vs.90%29.aspx[^].
 
One of the most advanced and, at the same time, easiest to use serialization is based on Data Contract. Please see: http://msdn.microsoft.com/en-us/library/ms733127.aspx[^].
 
Please see also my past answer where I advocate this approach:
How can I utilize XML File streamwriter and reader in my form application?[^],
Creating property files...[^].
 
—SA
  Permalink  
Comments
Espen Harlinn at 3-Feb-13 19:07pm
   
That's a nice reply, Sergey :-D
Sergey Alexandrovich Kryukov at 3-Feb-13 19:19pm
   
Thank you, Espen.
—SA
Nemanja Petrovic at 5-Feb-13 14:47pm
   
Thanks!
Sergey Alexandrovich Kryukov at 5-Feb-13 14:51pm
   
You are welcome.
Good luck, call again.
—SA

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

  Print Answers RSS
0 CPallini 235
1 DamithSL 225
2 OriginalGriff 198
3 George Jonsson 170
4 Maciej Los 165
0 OriginalGriff 5,305
1 DamithSL 4,382
2 Maciej Los 3,760
3 Kornfeld Eliyahu Peter 3,470
4 Sergey Alexandrovich Kryukov 2,901


Advertise | Privacy | Mobile
Web02 | 2.8.141216.1 | Last Updated 3 Feb 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100