22-12-2010, 02:25 PM
by
Group: BEGRP 26
Group: BEGRP 26
[attachment=7523]
Introduction
Developed in 1996 by an XML Working Group Set of tags are not fixed and can be extended
Maintain a structural relationship between them.
.NET Framework Library provides a good support to work with XML documents.
Introduction to Microsoft .NET XML Namespaces and Classes
.NET provides five namespace to support XML classes.
System.Xml
System.Xml.Schema
System.Xml.Serialization
System.Xml.XPath
System.Xml.Xsl
1) System.Xml
classes to read and write XML documents.
XmlReader
XmlTextReader
XmlValidatingReader
XmlNodeReader
XmlWriter
XmlTextWriter
2) System.Xml.Schema.
work with XML schemas
XmlSchema,
XmlSchemaAll, XmlSchemaXPath,
XmlSchemaType
3) System.Xml.Serialization
serialize objects into XML format documents or streams.
4) System.Xml.Xpath
Contains classes :
XPathDocument,
XPathExression,
XPathNavigator, XPathNodeIterator.
5) System.Xml.Xsl
Classes to work with XSL/T transformations
XmlReader class
Abstract bases classes and contains methods and properties to read a document.
Contains methods to navigate through a document nodes.
MoveToFirstAttribute
MoveToContent
MoveToFirstContent
MoveToNextAttribute
While reading…
Steps:
XmlTextReader tr = new XmlTextReader(“<file_path>");
tr.Read();
tr.MoveToElement()
Tr.MoveToAttribute()
XmlWriter Class
To write to XML documents.
An abstract base class for
XmlTextWriter
XmlNodeWriter
And some properties…..
Writing a document
XmlTextWriter tw = new XmlTextWriter(“<file_path>", null)
tw.WriteStartDocument(); tw.WriteEndDocument(); tw.Close();
Accessing a xml document
Methods to access properties of a class
Two classes,
XmlDocument
XmlDataDocument
Steps:
XmlDocument doc = new XmlDocument();
doc.Load(tr);
doc.Save();
Other methods to access a xml document
FileStream fs = new FileStream(path,FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
1.File path
2.How to open it - this can be set to Open, Write, or OpenWrite
3. FileAccess type - how the file is opened - there are a few different argument for this one
4.How to share the file with other applications while open
Database connectivity
ADO.NET provides functionality to read a database and write its contents to the XML document using data providers and a DataSet object.
Conclusion
C # has a good collection of classes to access a xml document
Operations are performed in terms of nodes
Wide class range to provide database interface