Session 4
Working with XML
Working with XML\ 2 of 29
Session Objectives Work with XML Work with XML using the DOM Discuss the Service Control Manager Create a Windows Service program Create a Service Configuration program
Working with XML\ 3 of 29
Introduction (1) XML forms an integral part of
computing Acts as a universal glue Binds together varied formats of
database to connect and exchange data C# applications can utilize and benefit
from XML
Working with XML\ 4 of 29
Introduction (2) The System.XML namespace handles
XML in .NET XMLReader & XMLWriter classes are
used to read and write XML documents XML Document Object Model
implementation in .NET
Working with XML\ 5 of 29
Introduction (3) Validating XML documents using the
XMLValidatingReader class Creating XML files from an ADO.NET
record set
Working with XML\ 6 of 29
System.XML namespace This namespace contains a number of
classes that help us process XML documents
XMLReader
XMLWriter
XMLTextReader
XMLTextWriter
XMLDocument
Working with XML\ 7 of 29
Writing an XML file (1) Example 1
Contd....
Working with XML\ 8 of 29
Writing an XML file (2)
Contd....
Working with XML\ 9 of 29
Output in an XML file Output -
Working with XML\ 10 of 29
Reading an XML file Example 2 -
Working with XML\ 11 of 29
Reading an XML file Output -
Working with XML\ 12 of 29
Validation Type property The XMLValidatingReader includes a
ValidationType property which is set to the type of validation that needs to be done
Working with XML\ 13 of 29
DTD file for XML Example 3
Working with XML\ 14 of 29
Validating XML data (1) Example 4
Contd....
Working with XML\ 15 of 29
Validating XML data (2) Example 4
Contd…
Working with XML\ 16 of 29
Validating XML data Output -
Working with XML\ 17 of 29
DOM in .NET (1) Example 4 -
Working with XML\ 18 of 29
DOM in .NET (2) Output -
Working with XML\ 19 of 29
Adding data to an XML document (1) Example 5
Contd....
Working with XML\ 20 of 29
Adding data to an XML document (2)
Contd....
Working with XML\ 21 of 29
Contents of Phone.XML Output -
Working with XML\ 22 of 29
Modifying data in an XML document (1) Example 6
Contd....
Working with XML\ 23 of 29
Modifying data in an XML document (2)
Contd…
Working with XML\ 24 of 29
Modifying data in an XML document
Output -
Working with XML\ 25 of 29
Phone.XML modified Output -
Working with XML\ 26 of 29
Writing an ADO.NET dataset to an XML file Example 7 -
Working with XML\ 27 of 29
MyProducts.XML Output -
Working with XML\ 28 of 29
Creating an ADO.NET dataset from an XML file (1) Example 8 -
Working with XML\ 29 of 29
Creating an ADO.NET dataset
from an XML file (2) Output -