Blog Home  Home Feed your aggregator (RSS 2.0)  
What did you learn today? - 70-552 Section II Part VI - XmlReader
Phil Denoncourt's Technology Rants
 
 Saturday, February 18, 2006

Read, write, and validate XML by using the XmlReader class and the XmlWriter class.

  • Read XML data by using the XmlReader class.
  • Read all XML element and attribute content.
  • Read specific element and attribute content.
  • Read XML data by using the XmlTextReader class.
  • Read node trees by using the XmlNodeReader class.
  • Validate XML data by using the XmlValidatingReader class.
  • Write XML data by using the XmlWriter class.

MSDN has an page on the new stuff as afar as XML is concerned.

The XmlReader provides readonly/forwardonly access to Xml Data.  To create an implementation of the XmlReader (XmlTextReader, XmlNodeReader, XmlValidatingReader), call the Create method.  The big change is that you can associate a Schema with a XmlReader, rather than having to fake it with XmlValidatingReader.

To read all the XML content, you can use the ReadInnerXml or ReadOuterXml methods.  To get a specific element, you call MoveToElement, and then read the content by using .Name or .Value properties.  To get a specific attribute, you would call either MoveToFirstAttribute or MoveToNextAttribute.

The XmlTextReader is a reader that enforces the rules of well-formed XML.  An XmlException is thrown when it encounters bad XML. 

The XmlNodeReader is a reader that works off an XmlDocument.  Functionally works the same as XmlReader.

The XmlValidatingReader is a reader that makes sure the XML conforms to known schemas contained in the Schemas collection.  This is now obsolete because the XmlReader now has this built in.

The XmlWriter contains all the methods necessary to write XML.  WriteStartElement, WriteEndElement, WriteStartAttribute, WriteEndAttribute, WriteCData, WriteComment....

Next up-> The rest of WinForm Controls

Saturday, February 18, 2006 12:22:46 AM (GMT Standard Time, UTC+00:00)  #    Comments [0]   Certifications  | 
Copyright © 2008 Phil Denoncourt III. All rights reserved.
DasBlog 'Portal' theme by Johnny Hughes.
Pick a theme: