Hello,
I'm new to XML and working on a searchable movie reader application which will read an XML file called MovieData.xml. The XML file contains the following nodes:
Example,
<movie>
<title>Silence of the Lambs</title>
<disc>5</disc>
<year>1991</year>
<director>Unspecified</director>
<cast>Unspecified</cast>
<genre>Horror</genre>
<riptype>DVDRip</riptype>
<codecvideo>DIVX</codecvideo>
<codecaudio>MP3</codecaudio>
<imdbrating>8.7</imdbrating>
<comments>Some Comments Here</comments>
</movie>
To read the XML data i'm using the following (simplified example).
// Example 1
static string xmlDocumentPath = @"MovieDat.xml";
static XmlDocument movieXmlDoc = new XmlDocument();
movieXmlDoc.Load(xmlDocumentPath); // Load the XML document
//
Then to read through the XML file I use,
//
string XmlPath = ("//class_movielist/movie/" + category); // Path to the selected node
XmlNodeList nodes = movieXmlDoc.SelectNodes(XmlPath);
foreach (XmlNode node in nodes)
{
// Code here
}
//
I hope i'm making sense so far.
The app works well but i'm wondering if I should add the 'XmlTextReader' to 'XmlDocument' object.
ie,
// Example 2
static string xmlDocumentPath = @"MovieDat.xml";
static XmlDocument movieXmlDoc = new XmlDocument( );
static XmlTextReader xmlTextRead = new XmlTextReader(xmlDocumentPath); // ?
movieXmlDoc.Load(xmlTextRead); // Load the XML document
//
Both examples work fine but what are the advantages/disadvantages between the two examples ?
I would be greatful for an explaination of the differences between the two.
Many Thanks
Steve H.