13.07.2015 Views

Applied XML Programming for Microsoft .NET.pdf - Csbdu.in

Applied XML Programming for Microsoft .NET.pdf - Csbdu.in

Applied XML Programming for Microsoft .NET.pdf - Csbdu.in

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Work<strong>in</strong>g with <strong>XML</strong> DocumentsTo be fully accessible, an <strong>XML</strong> document must be entirely loaded <strong>in</strong> memory and itsnodes and attributes mapped to relative objects derived from the XmlNode class. Theprocess that builds the <strong>XML</strong> DOM triggers when you call the Load method. You can usea variety of sources to <strong>in</strong>dicate the <strong>XML</strong> document to work on, <strong>in</strong>clud<strong>in</strong>g disk files andURLs and also streams and text readers.Load<strong>in</strong>g <strong>XML</strong> DocumentsThe Load method always trans<strong>for</strong>ms the data source <strong>in</strong>to an XmlTextReader object andpasses it down to an <strong>in</strong>ternal loader object, as shown here:public virtual void Load(Stream);public virtual void Load(str<strong>in</strong>g);public virtual void Load(TextReader);public virtual void Load(XmlReader);The loader is responsible <strong>for</strong> read<strong>in</strong>g all the nodes <strong>in</strong> the document and does thatthrough a nonvalidat<strong>in</strong>g reader. After a node has been read, it is analyzed and thecorrespond<strong>in</strong>g XmlNode object created and added to the document tree. The entireprocess is illustrated <strong>in</strong> Figure 5-4.Figure 5-4: The load<strong>in</strong>g process of an XmlDocument object.Note that be<strong>for</strong>e a new XmlDocument object is loaded, the current <strong>in</strong>stance of theXmlDocument object is cleared. This means that if you reuse the same <strong>in</strong>stance of theXmlDocument class to load a second document, the exist<strong>in</strong>g contents are entirelyremoved be<strong>for</strong>e proceed<strong>in</strong>g.182

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!