The default methods for dealing with xml in c# seem incredibly crude to me, leading me to suspect that I must be missing something in my searches. What is considered the standard best practices to parse xml files in c#?
I'm not sure whether "best practice for parsing xml" exists. There are numerous technologies suited for different situations. Which way to use depends on concrete scenario.
You can go with XLinq, XmlReader, XPathNavigator or even regular expressions. If you elaborate your needs I can try to give some suggestions.
What's wrong with XmlTextReader, XmlReader, XmlNodeReader and the System.Xml.XPath namespace? (XPathNavigator, XPathDocument, XPathExpression, XPathnodeIterator)?
Usually XPath makes reading XML easier, which is what you might be looking for.
If you're .NET 2.0, try XmlReader and it's subclasses XmlTextReader, XmlValidatingReader provide a fast, lightweight (memory usage etc), forward only way to parse an XML file.
If you need XPath capabilities try the XPathNavigator. If you need the entire document in memory try XmlDocument.
it's very simple, I know this is standard methods but you can create your own library to deal with that much better. Here is some examples:
XmlDocument xmlDoc= new XmlDocument(); //* create an xml document object.
xmlDoc.Load("yourXMLFile.xml"); //* load the XML document from the specified file.
//* Get elements.
XmlNodeList girlAddress = xmlDoc.GetElementsByTagName("gAddress");
XmlNodeList girlAge = xmlDoc.GetElementsByTagName("gAge");
XmlNodeList girlCellPhoneNumber = xmlDoc.GetElementsByTagName("gPhone");
//* Display the results.
Console.WriteLine("Address: " + girlAddress[0].InnerText);
Console.WriteLine("Age: " + girlAge[0].InnerText);
Console.WriteLine("Phone Number: " + girlCellPhoneNumber[0].InnerText);
Also there are some other methods to work with. f.ex here. And I think there are no one best method to do this, you always need to choose it by your self, what is most suitable for you.
Use a good XSD Schema to create a set of classes with xsd.exe and use an XmlSerializer to create a object tree out of your XML and vice versa. If you have few restrictions on your model, you could even try to create a direct mapping between you model classes and the XML with the Xml*Attributes.
There is an introductory article about XML Serialisation on MSDN.
Performance tip: Constructing an XmlSerializer is expensive. Keep a reference to your XmlSerializer instance if you intend to parse/write multiple XML files.
If you're processing a large amount of data (many megabytes) then you want to be using XmlReader to stream parse the XML. Anything else (XPathNavigator, XElement, XmlDocument and even XmlSerializer if you keep the full generated object graph) will result in high memory usage and also a very slow load time. Of course, if you need all the data in memory anyway, then you may not have much choice.
The DataSet.ReadXml method reads XML schema and data into the DataSet using the specified file. This link has a sample w3mentor c# xml parsing