SlideShare a Scribd company logo
Chapter'12
~'-:~~ :;:I I ~
dJ
;..,,1.,0ltt ·"'
UnitV
C:vrXML
r-~ I
Chapter Outline
12.1 Introduction: XML: Extensible Markup Language
12.2 XML Basics
12.3 The XML Classes
12.4 XML Validation
12.5 XML Display and Transforms
12.6 Questions
~ , -
L::~ ~l J~~~!_!J:._~~J/t:_ )
=It is a very widely used format for exchanging data, mainly because it's easy readable for
both humans and machines.
=XML is designed as an all-purpose format for organizing data.
=Amarkup language is used to provide information about a document.
=Tags are added to the document to provide the extra information.
=HTML tags tell abrowser how to display the document.
=XML tags give areader some idea what some of the data means.
_;_--~->~~.t ,,r,~ - .-. :/Sffl·.
---__,;::;...;;:....,;.;.£..,;:=~............-..;......._...:,.
When creating your own XML document, you need to remember only a few rules:
=XML documents must start with an XML declaration like <?xml version="1.0"?>.
=XML elements are composed of a start tag (like <Name>) and an end tag (like </Name>).
=Content is placed between the start and end tags. If you include a start tag, you must also
include a corresponding end tag.
= Whitespace between elements is ignored.
You can use only valid characters in the content for an element. You can't enter special
characters, such as the angle brackets (<>) and the ampersand (&), as content.
XML elements are case sensitive, so <ID> and <id> are completely different elements.
XML 317
:> All elements must be nested in a root element
:> Every element must be fully enclosed. In other words, when you open a subelement, you
need to close it before you can close the parent.
Example
<?xml version="1.0" encoding="utf-S" ?>
<address>
<name>
<first>Haider</first>
<last>Zaidi</last>
</name>
<email>haiderzaidi20@gmail.com</email>
<phone>8898253962</phone>
<birthday>
<year>1988</year>
<month>04</month>
<day>03</day>
</birthday>
</address>
XML File Tree
year day
:> .NET provides a rich set of classes for XML manipulation in several namespaces that start
with System.Xml.
:> NET provides seven namespace:
using System.Xml;
using System.Xml.Scherna;
using System.Xml.Linq;
/
"--
)
)
1n9
318
using System.Xml.Resolvers;
,, using System.Xml.Serialization;
using System.Xml.XPath;
using System.Xml.Xsl;
The SystemXml namespace contains major XML classes. This namespace contai·ns tnan
classes to read and write XML documents. Y
12.3.1 The XML TextWriter
One of the simplest ways to create or read any XML document is to use the ba .
XmITextWriter and XmlTextReader classes. sic
These classes work like their StreamWriter and StreamReader relatives, except th t th
write and read XML documents instead ofordinary text files. . a ey
Example: The following code creates an xmI file with the name Employee.
using System;
using System.Text;
using System.Xml;
namespace ConsoleApplication3
{
class Program
static void Main(stringO args)
{
XmlWriter xmlWriter =XmlWriter.Create("Employee.xml");
xmlWriter.WriteStartDocument();
xmlWriter.WriteStartElement("Employees");
xmlWriter.WriteStartElement("Employee");
xmlWriter.WriteAttributeString("age", "29");
xmlWriter.WriteString("Haider Zaidi");
xmlWriter.WriteEndElement();
xmlWriter.WriteStartElement("Employee");
xmlWriter.WriteAttributeString("age", "48");
xmlWriter.WriteString("Arif Patel");
xmlWriter.WriteEndDocument();
..,
l
)(r/lL 319
lJl)IWriter.WriteStartElement: Writes out a start tag with the specified local name.
xmtWriter.WriteElementString: Writes an element containing a string value.
lllllWriter.WriteEndDocument: Closes any open elements or attributes and puts the writer
k I
.0 the Start state.
bac
lJl)IWriter.WriteAttributeString: This method writes out the attribute with a user defined
espace prefix and associates it with the given namespace.
naJJl
12.3.2 XMLTextReader
:> With Xm!TextReader we parse XML data. This type acts upon a string containing XML
markup. We use the XmlTextReader constructor and develop a custom parser for XML data.
This is an efficient approach to XML parsing.
:> The Xm!Reader class is an abstract bases classes and contains methods and properties to
read adocument. The Read method reads a node in the stream.
:> I'm using books.xml to read and display its data through XmlTextReader. This file comes
with VS.NET samples (https://msdn.microsoftcom/en-
us/Iibrary/ms762271(v=vs.85).aspx ).
Example
using System;
using System.Text;
using System.Xml;
namespace ConsoleApplication1
class Program
static void args)
{// Create an isntance of XmlTextReader and call Read method to read the file
XmlTextReader textReader = new XmlTextReader("C:books.xml");
textReader.Read();
// If the node has value
while (textReader.Read())
{
II Move to fist element
textReader.MoveToElement();
Console.WriteLine("XmlTextReader Properties Test");
Console.WriteLine("===- =======");
// Read this element's properties and display them on console
Console.WriteLine("Name:" + textReader.Name);
Console.WriteLine("Base URI:" + textReader.BaseURI);
Console.WriteLine("Local Name:•+ textReader.LocalName);
N@1i%i@NAl+®'11
111D
Console.Writeline("Attribute Count:" +textReader.AttributeCount.ToString());
Console.Writeline("Depth:" +textReader.Depth.ToString());
Console.Writeline("Line Number:"+ textReader.LineNumber.ToString());
Console.Writeline("Node Type:" +textReader.NodeType.ToString());
Console.Writeline("Attribute Count:" + textReader.Value.ToString());
Console.Read();
file:.///C
:/USffl/N203TX/App0atall.ocal/Temporary ProJects/Consoli!Application1/bin:'Debu~ConsoleAppliotion1.EXE
•11un1111
--------=====------
ame:9enre ·
Base URI:file:///C:/books.xml
Local Name:genre
Attribute Count:0
Depth:2
Line Number:6
Node Type:EndElement
Attribute Count:
X
mlTextReader. Properties Test
-------------------
Name:
Base URI:file:///C:/books.xml
ocal Name:
Attribute Count:0
Depth:2
Line Number:6
Node Type:Whitespace
Attribute Count:
i•(·
12.2.3 Reading an XML Document
-
The XDocurnent makes it easy to read and navigate XML content. You can use the static
XDocurnent.Load() method to read XML documents from a file, URI, or stream, and you can use the
static XDocurnent.Parse() method to load XML content from a string.
Useful Methods for XElement and XDocurnent.
Method Description
Attributes() Gets the collection ofXAttribute objects for this element.
Attribute() Gets the XAttribute with the specific name.
Elements() Gets the collection ofXElement objects that are contained by this element. (This
is the top level only-these elements may in tum contain more elements.)
Optionally, you can specify an element name, and only those elements will be
retrieved. -
Element() Gets the single XElement contained by this element that has a specific name (or
null ifthere's no match). Ifthere is more than one matching element, this method
gets just the first one. -
• ru
Descendants() Gets the collection ofXElement objects that are contained by this element and
(optionally) have the name you specify. Unlike the Elements() method, this
method goes through all the layers ofthe document and finds elements at any
level of the hierarchy.
Nodes() Gets all the XNode objects contained by this element. This includes elements and
other content, such as comments. However, unlike the XmlTextReader class, the
XDocument does not consider attributes to be nodes.
~cendantNodes() Gets all the XNode object contained by this element. This method is like
Descendants() in that it drills down through all the layers ofnested elements.
These methods give you added flexibility to filter outjust the elements that interest you.
Example
Employee.xml
':'?xml version="1 .0" encoding="utf-8" ?>
<Employees>
<Employee>
<FirstName>ZAIDl</FirstName>
<Age>30</Age>
<Dept>Computer Science</Dept>
</Employee>
<Employee>
<FirstName>SAIF</FirstName>
<Age>30</Age>
<Dept>lnformation Technology</Dept>
</Employee>
<Employee>
<FirstName>ARIF</FirstName>
<Age>48</Age>
<Dept>Engineering</Dept>
</Employee>
<Employee>
<FirstName>SOHRABH</FirstName>
<Age>30</Age>
<Dept>M.Sc - IT</Dept>
</Employee>
</Employees>
Default.aspx :
---
322
dvanced Web Programming
_.,,. ,.- - __ .... .,..,,-
~ctDat~
.
.
DatabOund .. ~~tabound D•~! bound
DatabOund Databound Databound
Databound Databound 'Databound·
. : -· : ~~. ~-·~-· ~
··
DatabOund '•DatabOund .,, Databound
i: .•._,. . . ' -~....... :: . ,..
-'""'·.,. - ,-· -.- --~- '
DatabOund iDatabou~d, ,Databound , '
-..:~;..·--""~ ,.,_~ ---- "=' -..J._• ~:.,_
Default.aspx code
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" lnherits="_Def;;
%>
<html xmlns="http://wWW.w3.org/1999/xhtml">
<head runat="server">
</head>
<body>
<form id="form1" rimat="server">
<div>
<table ciass="sty1e1">
<td class="sty1e3">
<asp:GridView ID="GridView1• runat="server" BackColor="White" BorderColor="Whtte'
BorderWidth="2px" Ce11Padding="3" Gridlines="None" AutoGenerateColumns="False"
BorderStyle="Ridge" Height='281px" Width="538px"
onselectedindexchanged="GridView1_SelectedlndexChanged" CellSpacing='1"
Font-Bold='True" Font-Names="Arial Black' Font-Size='X-Large'>
<FooterStyle BackColor="#C6C3C6" ForeColor="Black"></FooterStyle>
<HeaderStyle BackColor="#4A3CBC" Font-Bold='True" ForeColor="#E7E7FF"></HeaderStyle>
<PagerStyle HorizontalAlign="Right" BackColor="#C6C3C6" ForeColor="Black">
</PagerStyle>
<RowStyle BackColor="#DEDFDE" ForeColor="Black" />
<SelectedRowStyle BackColor-"#9471DE' ForeColor="White"
Bold="True"></SelectedRowStyle>
<Columns>
<asp:BoundField DataField="FirstName· HeaderText="First Name' ReadOnly="true· />
Font•
~L ill
~asp:BoundField DataField="Age" HeaderText="Age" ReadOnly="true" />
<asp:BoundField DataField="Dept" HeaderText="Department" ReadOnly="true" />
</Columns>
<SortedAscendingCellStyle BackColor="#F1F1F1• />
<SortedAscendingHeaderStyle BackColor="#594B9C" />
<SortedDescendingCellStyle BackColor="#CAC9C9" />
<SortedDescendingHeaderStyle BackColor="#33276A• />
</asp:GridView></td>
</tr>
</table>
</div>
</form>
</body>
</html>
oefault.aspx.cs code
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Xml.Linq;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
XDocument document = XDocument.Load(@"F:ASP.NET
PROGEMPLOYEE.xml");
var query = from r in document.Descendants("Employee")
select new
FirstName = r.Element("FirstName").Value,
Age= r.Element("Age").Value,
Dept= r.Element("Dept").Value
RizviUnit 6LINQ
d
l
l
};
GridView1.DataSource =query;
GridView1.DataBind();
© ioc>"'°'t1S952JUNQ10XMI/DmUit.asp,
MiiMHMGAi+®ni41l
Select Data I
ZAIDI
SAIF nformation Technol~gyj
ARIF
~.
-~fr, ilf11r;~.-,~~·",
-'-_.,,,...,;.~~ -~- ; - - ~
XML bas arich set ofsupporting standards, many of which are far beyond the scope of this book.
One of the most useful in this family ofstandards is XML Schema. XML Schema defmes the rules to
which a specific XML document should conform, such as the allowable elements and attributes, the
order of elements, and the data type of each element. You define these requirements in an XML
Schema document (XSD).
Validating an XML Document
The following example shows you how to validate an XML document against a schema, using an
XmlReader that has validation features built in.
XML Schema (XSD)
The XML Schema language is also referred to as XML Schema Definition (XSD). An XML
Schema describes the structure ofan XML document.
XSD is a schema language; you use it to define the possible structure and contents of an XML
format A validating parser can then check whether an XML instance document conforms to an XSD
"lJ8 or a set ofschemas.
L t::__
XML 325
Example
<%@ Page Language="C#" AutoEventWireup="true"
lnherits="XmlValidalion" %>
<html xmlns="http://www.w3.org/1999/xhtm1" >
<head runat="server">
<title>Xml Validation</title>
</head>
<body>
<form id="form1• runat="server">
<div class="Box">
<asp:RadioButton id="optValid"
runat="server"
Text="Use Data.xml"
Checked="True"
GroupName="Valid">
</asp:RadioButton>
<asp:button id="crndValidate"
runat="server''
Text="Validate XML"
OnClick="cmdValidate_Click">
</asp:button>
</div>
<div>
CodeFile="Default.aspx.cs"
<asp:Label id="lblStatus" runat="server" EnableViewState="False"></asp:Label>
</div>
</form>
</body>
</html>
File: Default.aspx.cs
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.LIi;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
ng
32
using System.Web.UI.HtmlControls;
using System.Xml.Schema;
using System.IC;
using System.Xml;
public partial class XmlValidation : System.Web.UI.Page
{
protected void crndVal'date_Click(object sender, EventArgs e)
{
string filePath ="Data.xml";
lblStatus.Text ="";
XmlReaderSettings settings =new XmlReaderSettings();
settings.Schemas.Add("yourURI",Request.PhysicalApplicationPath +"Data.xsd");
settings.ValidationType= ValidationType.Schema;
settings.ValidationEventHandler += new ValidationEventHandler(ValidateHandler);
FileStream fs =new FileStream(filePath, FileMode.Open);
XmlReader r=XmlReader.Create(fs, settings);
while (r.Read())
{
l
ls.Close();
lblStatus.Text += "<br />Complete.";
}
public void ValidateHandler(Object sender, ValidationEventArgs e)
{
}
}
lblStatus.Text +="Error:"+ a.Message +"<br />';
File: Data.xml
<?xml version='1.0' encoding='utf-8' ?>
<EmployeeDetails>
<FirstName>ZAIDl</FirstName>
)(ML 327
.:MiddleName>ZARl</MiddleName>
<LastName>HAIDER~/LastName>
<Emai11d>haid~rzaidi20@gmail.com</Emailld>
.:Mobile>8898253962</Mobile>
-=:Address>B/503, Jogeshwari , Mumbai</Address>
<Blke>Yamaha FZS</Bike>
</EmployeeDetails>
File: Oata.xsd
Open the existing XML.
Go to XML menu.
·Select "Create schema"- option.
Your XSD will be created automatically.
<?xml version="1.0" encoding="utf-8"?>
<xs:schema. attributeFormDefault="unqualified"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="EmployeeDetails">
<xs:complexType>
<xs:sequence>
<xs:element name="FirstName" type="xs:string" />
<xs:element name="MiddleName" type="xs:string" />
<xs:element name="LastName" type="xs:string" />
<xs:element name="Emailld" type="xs:string" />
<xs:element name="Mobile" type="xs:unsignedLong"/>
<xs:element name="Address" type="xs:string" />
<xs:element name="Bike" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
t)l:s
·xMl,Display and:rrahsf-9~
1''.lS
elementFormDefault="qualified"
Another standard associated with XML is XSL Transformations (XSL'I). XSLT allows you to
create style sheets that can extract a portion of a large XML document or transform an XML document
into another type of XML document. An even more popular use of XSLT is to convert an XML
document into an HTML document that can be displayed in a browser.
XSLT is easy to use from the point of view of the .NET class library. All you need to understand
is how to create an XslCompiledTransform object (found in the Sys'tem.Xml.Xsl namespace). You use
wuuJiq
£ M%iiHMGPi+
its Load() method to specify a style sheet and its Transfonn() method to output the result to a fit
srreant e or
There are two main components in XSLT that helps transformations, XSLT Proces~o
formatter. First, the XSLT processor takes two inputs, a XML document and a XSLT sty! r ~
nd
XSL
XSLTprocessor starts from the root node and then it goes for the root node's children. Th:s ;et. lbe
searches the stylesheet element to see if any template element and other XSLT elements p ocessor
As per the defined XSLT rules it fetches data from the XML document and generates a are! defined.
. resu ts tr .
XML formal The XML formatter takes mput as a result tree and generates the final end ee 111
HTML. text other XML format. products as
The XML Web Control
The XML control is used to display an XML document or the results ofan XSL Tra ti
ns onn
Note: At least one of the XML Document properties must be set or no XML doc ·
ument ·
displayed. ts
. eoreit'
You can also specify an XSLT document that will fonnat the XML document b ti
written to the output. You can format the XML document with the Transfonn pro e
18
the TransfonnSource property. P rty or
Example
XML File: XMLFiJe.xml
<?xml version='1.0" encoding='utf-8' ?>
<breakfast_meru>
<food>
<name>Biriyani</name>
<price>$10.60</price>
<description>Rice with chicken</description>
<calories>650</calories>
</food>
<food>
<name>Juice</name>
<price>$4.20</price>
<description>Frult juices like mango, banana, apple</description>
<calories>200</calories>
</food>
</breakfast menu>
XML 329
XSLTFile
XSLTFile.xslt
'°:?xml version="1.0" encoding="iso-8859-1"?>
1 ....
' t 11;,
<html xsl:version="1.0"
xmlns="http://www.w3.org/1999/xhtml">
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
<body style="font-family:Arial;font-size:12pt;background-color:#EEEEEE">
<xsl:for-each select="breakfast_menu/food">
<div style="background-color:teal;color:white;padding:4px">
<span style="font-weight:bold">
<xsl:value-of select="name"/>
</span>
- <xsl:value-of select="price"/>
</div>
<div style="margin-left:20px;margin-bottom:1em;font-size:1Opt">
<xsl:value-of select="description"/>
<span style="font-style:italic">
<xsl:value-of select="calories"/> -
(calories per serving)
</span>
</div>
</xsl:for-each>
</body>
</html>
.... Xmn I
.., Use this <OfltnH to perfonn XSl trlmfonns.
{' · •
LaHI
Webforml.aspx source code
- ,e,•
Without XML Control
r.
_,,•-·.r,• :,-..
"Xlxxl
... . ..'.'./'!,'./
<%@ Page Language="C#"
lnherits="Webform1" %>
AutoEventWlreup="true" CodeFile="Webform1.aspx.cs"
---
<html xmlns="http:/Jwww.w3.org/1999/xhtml">
<head n1nat='server">
<ti11e></title>
</head>
<bOdy>
<form ld='form1' n1nat=·server">
<div>
<table class='style1'>
<td class='style3'>
dvancad Wab Prograrnrn1ng
<asp:Button ID='Button1' n1nat="server" Font-Bold="True" Font-Size="Larger"
ForeColor-"#003366' Height="33px" onclick="Button1_Click"
styte='font-weight: 700" Text="XML Display" />
<ltd>
<td>
<asp:Button ID="Button2" n1nat="server" Font-Bold="True" Font-Size="Larger"
ForeColor-"#003366" Height="33px" onclick="Button2_(?1ick'
styte='font-weight: 700" Text='Without XML Control "/>
<ltd>
</tr>
<td class='style6">
<asp:Xml ID="Xml1" runat="server"></asp:Xml>
<ltd>
<td class='style5">
<asp:Label ID="Label1" runat='server" Font-Bold="True" Font-Size="Large" I
Text='Label"></asp:Label>
<ltd>
</tr>
</table>
</div>
</form>
</body>
</html>
)(ML
+
C' 1,) ©"'
[ XML Display I
Webforml.aspx.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.IQ;
using System.Xml;
using System.Xml.Schema;
using System.Xml.XPath;
using System.Xml.Xsl;
using System.Web.UI;
using System.Text;
using System.Web.UI.WebControls;
public partial class Webform1 : System.Web.UI.Page
{
[ Without XML Control ]
Label
protected void Page_Load(object sender, EventArgs e)
{
protected void Button1_Click(object sender, EventArgs e)
{
XmI1.Visible = true;
Label1 .Visible =false;
// This is being read from the same folder as this page is in.(only for demo purpose)
// In real applications this xml might be coming from some external source or database.
string xmlString = File.ReadAIIText(Server.MapPath("XMLFile.xml"));
II Define the contents of the XML control
Xm11.DocumentContent =xmlString;
II Specify the XSL file to be used for transformation.
331
DD
&l¼i,H+MW?i+Wi,,hm!
Xml1 .TransformSource =Server.MapPath("XSLTFile.xslt");
}
protected void Button2_Click(object sender, EventArgs e)
{
Xml1.Visible =false;
Label1.Visible =true;
JI Getting file path
string strXSLTFile =Server.MapPath("XSLTFile.xslt");
string strXMLFile =Server.MapPath("XMLFile.xml");
II Creating XSLCompiled object
XslCompiledTransform objXSLTransform = new XslCompiledTransform();
objXSLTransform.Load(strXSLTFile);
II Creating StringBuilder object to hold html data and creates TextWriter object to hold data f
XslCompiled.Transform method rom
StringBuilder htrnlOu1put = new StringBuilder();
TextWriter htrnlWriter =new StringWriter(htmlOutput);
II Creating XmlReader object to read XML content
XmlReader reader= XmlReader.Create(strXMLFile);
II Call Transform() method to create html string and write in TextWriter object.
objXSLTransform.Transform(reader, null, htmlWriter);
Label1.Text =htmlOutput.ToString();
// Closing xmlreader object
reader.Close();
,
XML
333
1oe.n,o,t:614Z/Wtblorm1/Weblorn X +
© IOCalnost:t,l '1
® <:! Q . .. . . - ~---- - -
l~ ~
r.l""'.~;. -.m•,.,.-_
_
¼ ~,..,-i;:.· _ . '""'- ..,,. t;.... ....- .,. .,_,," _ ...
•
1
·• '" [!<ML Display I , [Without_
XML Control 
Biriyani - $10.60
Rice with chicken650 (calories per serving)
Juice - $4.20
i1
Frurt juices like mango, banana, apple200 (calories per serving)
loc,lloldlW#mforfflVWcllfo.-,· )(
I
~.: C! 0 ~-
f.XMl.;J}i~play
Biriyani - $10.60
Rlct with _151),_,,.,-inw
Juice - $4.20
FrultjulCIO 11<,-.bo111111, oppllm/-por-'"11/
ll!l@ -
·:i .'-:e;-z~-:~::.~:-~--~~~:.t~:f1~~~#~:@-:ii~~>r -:~/-.,;-~-~·:_
J ·:}J~~fflffY~-:~·-·:·
I. Explain xml with example.
2. Explain XML TextWriter with example.
3. Explain XML TextReader with example.
4. How to Reading an XML Document? Explain with example.
5. Explain XML Validation with proper example.
6. Explain XML Display and Transforms in asp.net with example.
Ad

More Related Content

What's hot (16)

DREF Friction Spinning.pptx
DREF Friction Spinning.pptxDREF Friction Spinning.pptx
DREF Friction Spinning.pptx
Jubayer Ahammed
 
Fsd lab 01 study on woven fabric analysis
Fsd lab 01 study on woven fabric analysisFsd lab 01 study on woven fabric analysis
Fsd lab 01 study on woven fabric analysis
Mahbubay Rabbani Mim
 
غیراللہ کی پکار کی شرعی حیثیت | Ghairullah ki pukar ki sharaie haisiat
غیراللہ کی پکار کی شرعی حیثیت | Ghairullah ki pukar ki sharaie haisiatغیراللہ کی پکار کی شرعی حیثیت | Ghairullah ki pukar ki sharaie haisiat
غیراللہ کی پکار کی شرعی حیثیت | Ghairullah ki pukar ki sharaie haisiat
Quran Juz (Para)
 
مستويات القياس
مستويات القياسمستويات القياس
مستويات القياس
wardahhumaira
 
استراتيجيات التدريس الفعال
استراتيجيات التدريس الفعالاستراتيجيات التدريس الفعال
استراتيجيات التدريس الفعال
منتدى الرياضيات المتقدمة
 
Project on modern textile pretreatment
Project on modern textile pretreatment Project on modern textile pretreatment
Project on modern textile pretreatment
Bangladesh University of Textiles
 
Water proof breathable fabrics by Vignesh Dhanabalan
Water proof breathable fabrics   by Vignesh DhanabalanWater proof breathable fabrics   by Vignesh Dhanabalan
Water proof breathable fabrics by Vignesh Dhanabalan
Vignesh Dhanabalan
 
Terry towel manufacturing
Terry towel manufacturingTerry towel manufacturing
Terry towel manufacturing
shariful islam
 
الدليل الاجرائي لاستراتيجيات التعلم النشط
الدليل الاجرائي لاستراتيجيات التعلم النشطالدليل الاجرائي لاستراتيجيات التعلم النشط
الدليل الاجرائي لاستراتيجيات التعلم النشط
د.فداء الشنيقات
 
Textile Calculations and Equations
Textile  Calculations and EquationsTextile  Calculations and Equations
Textile Calculations and Equations
Md. Mazadul Hasan Shishir
 
السبورات التفاعلية في الدرس التزامني
السبورات التفاعلية في الدرس التزامنيالسبورات التفاعلية في الدرس التزامني
السبورات التفاعلية في الدرس التزامني
رؤية للحقائب التدريبية
 
قواعد البيانات
قواعد البياناتقواعد البيانات
قواعد البيانات
Moselhy Hussein
 
Study on Feed System of a Knitting Machine.
Study on Feed System of a Knitting Machine.Study on Feed System of a Knitting Machine.
Study on Feed System of a Knitting Machine.
BGMEA University of Fashion & Technology
 
Nonwoven textiles - characteristics, production methods, uses
Nonwoven textiles - characteristics, production methods, usesNonwoven textiles - characteristics, production methods, uses
Nonwoven textiles - characteristics, production methods, uses
Magdalena Georgievska
 
Different techniques of sizing
Different techniques of sizingDifferent techniques of sizing
Different techniques of sizing
Swaraz Mollick
 
الحروف التي تنطق ولا تكتب.pptx
الحروف التي تنطق ولا تكتب.pptxالحروف التي تنطق ولا تكتب.pptx
الحروف التي تنطق ولا تكتب.pptx
DrSaadMeqdad
 
DREF Friction Spinning.pptx
DREF Friction Spinning.pptxDREF Friction Spinning.pptx
DREF Friction Spinning.pptx
Jubayer Ahammed
 
Fsd lab 01 study on woven fabric analysis
Fsd lab 01 study on woven fabric analysisFsd lab 01 study on woven fabric analysis
Fsd lab 01 study on woven fabric analysis
Mahbubay Rabbani Mim
 
غیراللہ کی پکار کی شرعی حیثیت | Ghairullah ki pukar ki sharaie haisiat
غیراللہ کی پکار کی شرعی حیثیت | Ghairullah ki pukar ki sharaie haisiatغیراللہ کی پکار کی شرعی حیثیت | Ghairullah ki pukar ki sharaie haisiat
غیراللہ کی پکار کی شرعی حیثیت | Ghairullah ki pukar ki sharaie haisiat
Quran Juz (Para)
 
مستويات القياس
مستويات القياسمستويات القياس
مستويات القياس
wardahhumaira
 
Water proof breathable fabrics by Vignesh Dhanabalan
Water proof breathable fabrics   by Vignesh DhanabalanWater proof breathable fabrics   by Vignesh Dhanabalan
Water proof breathable fabrics by Vignesh Dhanabalan
Vignesh Dhanabalan
 
Terry towel manufacturing
Terry towel manufacturingTerry towel manufacturing
Terry towel manufacturing
shariful islam
 
الدليل الاجرائي لاستراتيجيات التعلم النشط
الدليل الاجرائي لاستراتيجيات التعلم النشطالدليل الاجرائي لاستراتيجيات التعلم النشط
الدليل الاجرائي لاستراتيجيات التعلم النشط
د.فداء الشنيقات
 
قواعد البيانات
قواعد البياناتقواعد البيانات
قواعد البيانات
Moselhy Hussein
 
Nonwoven textiles - characteristics, production methods, uses
Nonwoven textiles - characteristics, production methods, usesNonwoven textiles - characteristics, production methods, uses
Nonwoven textiles - characteristics, production methods, uses
Magdalena Georgievska
 
Different techniques of sizing
Different techniques of sizingDifferent techniques of sizing
Different techniques of sizing
Swaraz Mollick
 
الحروف التي تنطق ولا تكتب.pptx
الحروف التي تنطق ولا تكتب.pptxالحروف التي تنطق ولا تكتب.pptx
الحروف التي تنطق ولا تكتب.pptx
DrSaadMeqdad
 

Similar to Advanced Web Programming Chapter 12 (20)

Xml writers
Xml writersXml writers
Xml writers
Raghu nath
 
The xml
The xmlThe xml
The xml
Raghu nath
 
Chapter 18
Chapter 18Chapter 18
Chapter 18
application developer
 
XML Schema.pptx
XML Schema.pptxXML Schema.pptx
XML Schema.pptx
JohnsonDcunha1
 
XML
XMLXML
XML
baabtra.com - No. 1 supplier of quality freshers
 
Xml processing in scala
Xml processing in scalaXml processing in scala
Xml processing in scala
Neelkanth Sachdeva
 
Xml processing in scala
Xml processing in scalaXml processing in scala
Xml processing in scala
Knoldus Inc.
 
Java XML Parsing
Java XML ParsingJava XML Parsing
Java XML Parsing
srinivasanjayakumar
 
06 xml processing-in-.net
06 xml processing-in-.net06 xml processing-in-.net
06 xml processing-in-.net
glubox
 
programming with xml for graduate students
programming with xml for graduate studentsprogramming with xml for graduate students
programming with xml for graduate students
RameshPrasadBhatta2
 
XML stands for EXtensible Markup Language
XML stands for EXtensible Markup LanguageXML stands for EXtensible Markup Language
XML stands for EXtensible Markup Language
NetajiGandi1
 
Basics of XML
Basics of XMLBasics of XML
Basics of XML
indiangarg
 
XML Tools for Perl
XML Tools for PerlXML Tools for Perl
XML Tools for Perl
Geir Aalberg
 
ASP.Net Presentation Part2
ASP.Net Presentation Part2ASP.Net Presentation Part2
ASP.Net Presentation Part2
Neeraj Mathur
 
Extensible markup language attacks
Extensible markup language attacksExtensible markup language attacks
Extensible markup language attacks
n|u - The Open Security Community
 
Simple xml in .net
Simple xml in .netSimple xml in .net
Simple xml in .net
Vi Vo Hung
 
Applied xml programming for microsoft 2
Applied xml programming for microsoft  2Applied xml programming for microsoft  2
Applied xml programming for microsoft 2
Raghu nath
 
Xsd examples
Xsd examplesXsd examples
Xsd examples
Bình Trọng Án
 
Ch23 xml processing_with_java
Ch23 xml processing_with_javaCh23 xml processing_with_java
Ch23 xml processing_with_java
ardnetij
 
Ch23
Ch23Ch23
Ch23
preetamju
 
Ad

More from RohanMistry15 (20)

software-quality-assurance question paper 2023
software-quality-assurance question paper 2023software-quality-assurance question paper 2023
software-quality-assurance question paper 2023
RohanMistry15
 
security-in-computing question paper 2023
security-in-computing question paper 2023security-in-computing question paper 2023
security-in-computing question paper 2023
RohanMistry15
 
IT-service-management question paper 2023
IT-service-management question paper 2023IT-service-management question paper 2023
IT-service-management question paper 2023
RohanMistry15
 
geographical-information-system question paper
geographical-information-system question papergeographical-information-system question paper
geographical-information-system question paper
RohanMistry15
 
Business-Intelligence question paper 2023
Business-Intelligence question paper 2023Business-Intelligence question paper 2023
Business-Intelligence question paper 2023
RohanMistry15
 
Aeronautical Engineering Career Information
Aeronautical Engineering Career InformationAeronautical Engineering Career Information
Aeronautical Engineering Career Information
RohanMistry15
 
Chinese Cyber attack on mumbai power plant
Chinese Cyber attack on mumbai power plantChinese Cyber attack on mumbai power plant
Chinese Cyber attack on mumbai power plant
RohanMistry15
 
Zeus learning
Zeus learningZeus learning
Zeus learning
RohanMistry15
 
Advanced Web Programming Chapter 8
Advanced Web Programming Chapter 8Advanced Web Programming Chapter 8
Advanced Web Programming Chapter 8
RohanMistry15
 
Advanced Web Programming Chapter 5
Advanced Web Programming Chapter 5Advanced Web Programming Chapter 5
Advanced Web Programming Chapter 5
RohanMistry15
 
Advanced Web Programming Chapter 4
Advanced Web Programming Chapter 4Advanced Web Programming Chapter 4
Advanced Web Programming Chapter 4
RohanMistry15
 
Advanced Web Programming Chapter 13 & 14
Advanced Web Programming Chapter 13 & 14Advanced Web Programming Chapter 13 & 14
Advanced Web Programming Chapter 13 & 14
RohanMistry15
 
Advanced Web Programming Chapter 2
Advanced Web Programming Chapter 2Advanced Web Programming Chapter 2
Advanced Web Programming Chapter 2
RohanMistry15
 
Advanced Web Programming Chapter 3
Advanced Web Programming Chapter 3Advanced Web Programming Chapter 3
Advanced Web Programming Chapter 3
RohanMistry15
 
Advanced Web Programming Chapter 10
Advanced Web Programming  Chapter 10Advanced Web Programming  Chapter 10
Advanced Web Programming Chapter 10
RohanMistry15
 
Advanced Web Programming Chapter 11
Advanced Web Programming Chapter 11Advanced Web Programming Chapter 11
Advanced Web Programming Chapter 11
RohanMistry15
 
Advanced Web Programming Chapter 9
Advanced Web Programming Chapter 9Advanced Web Programming Chapter 9
Advanced Web Programming Chapter 9
RohanMistry15
 
Advanced Web Programming Chapter 6
Advanced Web Programming Chapter 6Advanced Web Programming Chapter 6
Advanced Web Programming Chapter 6
RohanMistry15
 
Advanced Web Programming Chapter 1
Advanced Web Programming Chapter 1Advanced Web Programming Chapter 1
Advanced Web Programming Chapter 1
RohanMistry15
 
Advanced Web Programming Chapter 7
Advanced Web Programming Chapter 7Advanced Web Programming Chapter 7
Advanced Web Programming Chapter 7
RohanMistry15
 
software-quality-assurance question paper 2023
software-quality-assurance question paper 2023software-quality-assurance question paper 2023
software-quality-assurance question paper 2023
RohanMistry15
 
security-in-computing question paper 2023
security-in-computing question paper 2023security-in-computing question paper 2023
security-in-computing question paper 2023
RohanMistry15
 
IT-service-management question paper 2023
IT-service-management question paper 2023IT-service-management question paper 2023
IT-service-management question paper 2023
RohanMistry15
 
geographical-information-system question paper
geographical-information-system question papergeographical-information-system question paper
geographical-information-system question paper
RohanMistry15
 
Business-Intelligence question paper 2023
Business-Intelligence question paper 2023Business-Intelligence question paper 2023
Business-Intelligence question paper 2023
RohanMistry15
 
Aeronautical Engineering Career Information
Aeronautical Engineering Career InformationAeronautical Engineering Career Information
Aeronautical Engineering Career Information
RohanMistry15
 
Chinese Cyber attack on mumbai power plant
Chinese Cyber attack on mumbai power plantChinese Cyber attack on mumbai power plant
Chinese Cyber attack on mumbai power plant
RohanMistry15
 
Advanced Web Programming Chapter 8
Advanced Web Programming Chapter 8Advanced Web Programming Chapter 8
Advanced Web Programming Chapter 8
RohanMistry15
 
Advanced Web Programming Chapter 5
Advanced Web Programming Chapter 5Advanced Web Programming Chapter 5
Advanced Web Programming Chapter 5
RohanMistry15
 
Advanced Web Programming Chapter 4
Advanced Web Programming Chapter 4Advanced Web Programming Chapter 4
Advanced Web Programming Chapter 4
RohanMistry15
 
Advanced Web Programming Chapter 13 & 14
Advanced Web Programming Chapter 13 & 14Advanced Web Programming Chapter 13 & 14
Advanced Web Programming Chapter 13 & 14
RohanMistry15
 
Advanced Web Programming Chapter 2
Advanced Web Programming Chapter 2Advanced Web Programming Chapter 2
Advanced Web Programming Chapter 2
RohanMistry15
 
Advanced Web Programming Chapter 3
Advanced Web Programming Chapter 3Advanced Web Programming Chapter 3
Advanced Web Programming Chapter 3
RohanMistry15
 
Advanced Web Programming Chapter 10
Advanced Web Programming  Chapter 10Advanced Web Programming  Chapter 10
Advanced Web Programming Chapter 10
RohanMistry15
 
Advanced Web Programming Chapter 11
Advanced Web Programming Chapter 11Advanced Web Programming Chapter 11
Advanced Web Programming Chapter 11
RohanMistry15
 
Advanced Web Programming Chapter 9
Advanced Web Programming Chapter 9Advanced Web Programming Chapter 9
Advanced Web Programming Chapter 9
RohanMistry15
 
Advanced Web Programming Chapter 6
Advanced Web Programming Chapter 6Advanced Web Programming Chapter 6
Advanced Web Programming Chapter 6
RohanMistry15
 
Advanced Web Programming Chapter 1
Advanced Web Programming Chapter 1Advanced Web Programming Chapter 1
Advanced Web Programming Chapter 1
RohanMistry15
 
Advanced Web Programming Chapter 7
Advanced Web Programming Chapter 7Advanced Web Programming Chapter 7
Advanced Web Programming Chapter 7
RohanMistry15
 
Ad

Recently uploaded (20)

Build Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For DevsBuild Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For Devs
Brian McKeiver
 
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes
 
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven InsightsAndrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell
 
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In FranceManifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
chb3
 
Top 10 IT Help Desk Outsourcing Services
Top 10 IT Help Desk Outsourcing ServicesTop 10 IT Help Desk Outsourcing Services
Top 10 IT Help Desk Outsourcing Services
Infrassist Technologies Pvt. Ltd.
 
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager APIUiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPathCommunity
 
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdfThe Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
Abi john
 
Procurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptxProcurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptx
Jon Hansen
 
Cyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of securityCyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of security
riccardosl1
 
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath MaestroDev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
UiPathCommunity
 
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
organizerofv
 
Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)
Ortus Solutions, Corp
 
Semantic Cultivators : The Critical Future Role to Enable AI
Semantic Cultivators : The Critical Future Role to Enable AISemantic Cultivators : The Critical Future Role to Enable AI
Semantic Cultivators : The Critical Future Role to Enable AI
artmondano
 
tecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdftecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdf
fjgm517
 
TrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business ConsultingTrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business Consulting
Trs Labs
 
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-UmgebungenHCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
panagenda
 
AI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global TrendsAI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global Trends
InData Labs
 
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptxSpecial Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
shyamraj55
 
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc
 
Electronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploitElectronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploit
niftliyevhuseyn
 
Build Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For DevsBuild Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For Devs
Brian McKeiver
 
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes
 
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven InsightsAndrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell
 
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In FranceManifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
chb3
 
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager APIUiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPathCommunity
 
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdfThe Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
Abi john
 
Procurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptxProcurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptx
Jon Hansen
 
Cyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of securityCyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of security
riccardosl1
 
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath MaestroDev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
UiPathCommunity
 
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
organizerofv
 
Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)
Ortus Solutions, Corp
 
Semantic Cultivators : The Critical Future Role to Enable AI
Semantic Cultivators : The Critical Future Role to Enable AISemantic Cultivators : The Critical Future Role to Enable AI
Semantic Cultivators : The Critical Future Role to Enable AI
artmondano
 
tecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdftecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdf
fjgm517
 
TrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business ConsultingTrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business Consulting
Trs Labs
 
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-UmgebungenHCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
panagenda
 
AI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global TrendsAI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global Trends
InData Labs
 
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptxSpecial Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
shyamraj55
 
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc
 
Electronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploitElectronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploit
niftliyevhuseyn
 

Advanced Web Programming Chapter 12

  • 1. Chapter'12 ~'-:~~ :;:I I ~ dJ ;..,,1.,0ltt ·"' UnitV C:vrXML r-~ I Chapter Outline 12.1 Introduction: XML: Extensible Markup Language 12.2 XML Basics 12.3 The XML Classes 12.4 XML Validation 12.5 XML Display and Transforms 12.6 Questions ~ , - L::~ ~l J~~~!_!J:._~~J/t:_ ) =It is a very widely used format for exchanging data, mainly because it's easy readable for both humans and machines. =XML is designed as an all-purpose format for organizing data. =Amarkup language is used to provide information about a document. =Tags are added to the document to provide the extra information. =HTML tags tell abrowser how to display the document. =XML tags give areader some idea what some of the data means. _;_--~->~~.t ,,r,~ - .-. :/Sffl·. ---__,;::;...;;:....,;.;.£..,;:=~............-..;......._...:,. When creating your own XML document, you need to remember only a few rules: =XML documents must start with an XML declaration like <?xml version="1.0"?>. =XML elements are composed of a start tag (like <Name>) and an end tag (like </Name>). =Content is placed between the start and end tags. If you include a start tag, you must also include a corresponding end tag. = Whitespace between elements is ignored. You can use only valid characters in the content for an element. You can't enter special characters, such as the angle brackets (<>) and the ampersand (&), as content. XML elements are case sensitive, so <ID> and <id> are completely different elements.
  • 2. XML 317 :> All elements must be nested in a root element :> Every element must be fully enclosed. In other words, when you open a subelement, you need to close it before you can close the parent. Example <?xml version="1.0" encoding="utf-S" ?> <address> <name> <first>Haider</first> <last>Zaidi</last> </name> <email>[email protected]</email> <phone>8898253962</phone> <birthday> <year>1988</year> <month>04</month> <day>03</day> </birthday> </address> XML File Tree year day :> .NET provides a rich set of classes for XML manipulation in several namespaces that start with System.Xml. :> NET provides seven namespace: using System.Xml; using System.Xml.Scherna; using System.Xml.Linq; / "--
  • 3. ) ) 1n9 318 using System.Xml.Resolvers; ,, using System.Xml.Serialization; using System.Xml.XPath; using System.Xml.Xsl; The SystemXml namespace contains major XML classes. This namespace contai·ns tnan classes to read and write XML documents. Y 12.3.1 The XML TextWriter One of the simplest ways to create or read any XML document is to use the ba . XmITextWriter and XmlTextReader classes. sic These classes work like their StreamWriter and StreamReader relatives, except th t th write and read XML documents instead ofordinary text files. . a ey Example: The following code creates an xmI file with the name Employee. using System; using System.Text; using System.Xml; namespace ConsoleApplication3 { class Program static void Main(stringO args) { XmlWriter xmlWriter =XmlWriter.Create("Employee.xml"); xmlWriter.WriteStartDocument(); xmlWriter.WriteStartElement("Employees"); xmlWriter.WriteStartElement("Employee"); xmlWriter.WriteAttributeString("age", "29"); xmlWriter.WriteString("Haider Zaidi"); xmlWriter.WriteEndElement(); xmlWriter.WriteStartElement("Employee"); xmlWriter.WriteAttributeString("age", "48"); xmlWriter.WriteString("Arif Patel"); xmlWriter.WriteEndDocument();
  • 4. .., l )(r/lL 319 lJl)IWriter.WriteStartElement: Writes out a start tag with the specified local name. xmtWriter.WriteElementString: Writes an element containing a string value. lllllWriter.WriteEndDocument: Closes any open elements or attributes and puts the writer k I .0 the Start state. bac lJl)IWriter.WriteAttributeString: This method writes out the attribute with a user defined espace prefix and associates it with the given namespace. naJJl 12.3.2 XMLTextReader :> With Xm!TextReader we parse XML data. This type acts upon a string containing XML markup. We use the XmlTextReader constructor and develop a custom parser for XML data. This is an efficient approach to XML parsing. :> The Xm!Reader class is an abstract bases classes and contains methods and properties to read adocument. The Read method reads a node in the stream. :> I'm using books.xml to read and display its data through XmlTextReader. This file comes with VS.NET samples (https://msdn.microsoftcom/en- us/Iibrary/ms762271(v=vs.85).aspx ). Example using System; using System.Text; using System.Xml; namespace ConsoleApplication1 class Program static void args) {// Create an isntance of XmlTextReader and call Read method to read the file XmlTextReader textReader = new XmlTextReader("C:books.xml"); textReader.Read(); // If the node has value while (textReader.Read()) { II Move to fist element textReader.MoveToElement(); Console.WriteLine("XmlTextReader Properties Test"); Console.WriteLine("===- ======="); // Read this element's properties and display them on console Console.WriteLine("Name:" + textReader.Name); Console.WriteLine("Base URI:" + textReader.BaseURI); Console.WriteLine("Local Name:•+ textReader.LocalName);
  • 5. N@1i%i@NAl+®'11 111D Console.Writeline("Attribute Count:" +textReader.AttributeCount.ToString()); Console.Writeline("Depth:" +textReader.Depth.ToString()); Console.Writeline("Line Number:"+ textReader.LineNumber.ToString()); Console.Writeline("Node Type:" +textReader.NodeType.ToString()); Console.Writeline("Attribute Count:" + textReader.Value.ToString()); Console.Read(); file:.///C :/USffl/N203TX/App0atall.ocal/Temporary ProJects/Consoli!Application1/bin:'Debu~ConsoleAppliotion1.EXE •11un1111 --------=====------ ame:9enre · Base URI:file:///C:/books.xml Local Name:genre Attribute Count:0 Depth:2 Line Number:6 Node Type:EndElement Attribute Count: X mlTextReader. Properties Test ------------------- Name: Base URI:file:///C:/books.xml ocal Name: Attribute Count:0 Depth:2 Line Number:6 Node Type:Whitespace Attribute Count: i•(· 12.2.3 Reading an XML Document - The XDocurnent makes it easy to read and navigate XML content. You can use the static XDocurnent.Load() method to read XML documents from a file, URI, or stream, and you can use the static XDocurnent.Parse() method to load XML content from a string. Useful Methods for XElement and XDocurnent. Method Description Attributes() Gets the collection ofXAttribute objects for this element. Attribute() Gets the XAttribute with the specific name. Elements() Gets the collection ofXElement objects that are contained by this element. (This is the top level only-these elements may in tum contain more elements.) Optionally, you can specify an element name, and only those elements will be retrieved. - Element() Gets the single XElement contained by this element that has a specific name (or null ifthere's no match). Ifthere is more than one matching element, this method gets just the first one. -
  • 6. • ru Descendants() Gets the collection ofXElement objects that are contained by this element and (optionally) have the name you specify. Unlike the Elements() method, this method goes through all the layers ofthe document and finds elements at any level of the hierarchy. Nodes() Gets all the XNode objects contained by this element. This includes elements and other content, such as comments. However, unlike the XmlTextReader class, the XDocument does not consider attributes to be nodes. ~cendantNodes() Gets all the XNode object contained by this element. This method is like Descendants() in that it drills down through all the layers ofnested elements. These methods give you added flexibility to filter outjust the elements that interest you. Example Employee.xml ':'?xml version="1 .0" encoding="utf-8" ?> <Employees> <Employee> <FirstName>ZAIDl</FirstName> <Age>30</Age> <Dept>Computer Science</Dept> </Employee> <Employee> <FirstName>SAIF</FirstName> <Age>30</Age> <Dept>lnformation Technology</Dept> </Employee> <Employee> <FirstName>ARIF</FirstName> <Age>48</Age> <Dept>Engineering</Dept> </Employee> <Employee> <FirstName>SOHRABH</FirstName> <Age>30</Age> <Dept>M.Sc - IT</Dept> </Employee> </Employees> Default.aspx :
  • 7. --- 322 dvanced Web Programming _.,,. ,.- - __ .... .,..,,- ~ctDat~ . . DatabOund .. ~~tabound D•~! bound DatabOund Databound Databound Databound Databound 'Databound· . : -· : ~~. ~-·~-· ~ ·· DatabOund '•DatabOund .,, Databound i: .•._,. . . ' -~....... :: . ,.. -'""'·.,. - ,-· -.- --~- ' DatabOund iDatabou~d, ,Databound , ' -..:~;..·--""~ ,.,_~ ---- "=' -..J._• ~:.,_ Default.aspx code <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" lnherits="_Def;; %> <html xmlns="http://wWW.w3.org/1999/xhtml"> <head runat="server"> </head> <body> <form id="form1" rimat="server"> <div> <table ciass="sty1e1"> <td class="sty1e3"> <asp:GridView ID="GridView1• runat="server" BackColor="White" BorderColor="Whtte' BorderWidth="2px" Ce11Padding="3" Gridlines="None" AutoGenerateColumns="False" BorderStyle="Ridge" Height='281px" Width="538px" onselectedindexchanged="GridView1_SelectedlndexChanged" CellSpacing='1" Font-Bold='True" Font-Names="Arial Black' Font-Size='X-Large'> <FooterStyle BackColor="#C6C3C6" ForeColor="Black"></FooterStyle> <HeaderStyle BackColor="#4A3CBC" Font-Bold='True" ForeColor="#E7E7FF"></HeaderStyle> <PagerStyle HorizontalAlign="Right" BackColor="#C6C3C6" ForeColor="Black"> </PagerStyle> <RowStyle BackColor="#DEDFDE" ForeColor="Black" /> <SelectedRowStyle BackColor-"#9471DE' ForeColor="White" Bold="True"></SelectedRowStyle> <Columns> <asp:BoundField DataField="FirstName· HeaderText="First Name' ReadOnly="true· /> Font•
  • 8. ~L ill ~asp:BoundField DataField="Age" HeaderText="Age" ReadOnly="true" /> <asp:BoundField DataField="Dept" HeaderText="Department" ReadOnly="true" /> </Columns> <SortedAscendingCellStyle BackColor="#F1F1F1• /> <SortedAscendingHeaderStyle BackColor="#594B9C" /> <SortedDescendingCellStyle BackColor="#CAC9C9" /> <SortedDescendingHeaderStyle BackColor="#33276A• /> </asp:GridView></td> </tr> </table> </div> </form> </body> </html> oefault.aspx.cs code using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Xml.Linq; public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void Button1_Click(object sender, EventArgs e) { XDocument document = XDocument.Load(@"F:ASP.NET PROGEMPLOYEE.xml"); var query = from r in document.Descendants("Employee") select new FirstName = r.Element("FirstName").Value, Age= r.Element("Age").Value, Dept= r.Element("Dept").Value RizviUnit 6LINQ
  • 9. d l l }; GridView1.DataSource =query; GridView1.DataBind(); © ioc>"'°'t1S952JUNQ10XMI/DmUit.asp, MiiMHMGAi+®ni41l Select Data I ZAIDI SAIF nformation Technol~gyj ARIF ~. -~fr, ilf11r;~.-,~~·", -'-_.,,,...,;.~~ -~- ; - - ~ XML bas arich set ofsupporting standards, many of which are far beyond the scope of this book. One of the most useful in this family ofstandards is XML Schema. XML Schema defmes the rules to which a specific XML document should conform, such as the allowable elements and attributes, the order of elements, and the data type of each element. You define these requirements in an XML Schema document (XSD). Validating an XML Document The following example shows you how to validate an XML document against a schema, using an XmlReader that has validation features built in. XML Schema (XSD) The XML Schema language is also referred to as XML Schema Definition (XSD). An XML Schema describes the structure ofan XML document. XSD is a schema language; you use it to define the possible structure and contents of an XML format A validating parser can then check whether an XML instance document conforms to an XSD "lJ8 or a set ofschemas. L t::__
  • 10. XML 325 Example <%@ Page Language="C#" AutoEventWireup="true" lnherits="XmlValidalion" %> <html xmlns="http://www.w3.org/1999/xhtm1" > <head runat="server"> <title>Xml Validation</title> </head> <body> <form id="form1• runat="server"> <div class="Box"> <asp:RadioButton id="optValid" runat="server" Text="Use Data.xml" Checked="True" GroupName="Valid"> </asp:RadioButton> <asp:button id="crndValidate" runat="server'' Text="Validate XML" OnClick="cmdValidate_Click"> </asp:button> </div> <div> CodeFile="Default.aspx.cs" <asp:Label id="lblStatus" runat="server" EnableViewState="False"></asp:Label> </div> </form> </body> </html> File: Default.aspx.cs using System; using System.Data; using System.Configuration; using System.Collections; using System.Web; using System.Web.Security; using System.Web.LIi; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts;
  • 11. ng 32 using System.Web.UI.HtmlControls; using System.Xml.Schema; using System.IC; using System.Xml; public partial class XmlValidation : System.Web.UI.Page { protected void crndVal'date_Click(object sender, EventArgs e) { string filePath ="Data.xml"; lblStatus.Text =""; XmlReaderSettings settings =new XmlReaderSettings(); settings.Schemas.Add("yourURI",Request.PhysicalApplicationPath +"Data.xsd"); settings.ValidationType= ValidationType.Schema; settings.ValidationEventHandler += new ValidationEventHandler(ValidateHandler); FileStream fs =new FileStream(filePath, FileMode.Open); XmlReader r=XmlReader.Create(fs, settings); while (r.Read()) { l ls.Close(); lblStatus.Text += "<br />Complete."; } public void ValidateHandler(Object sender, ValidationEventArgs e) { } } lblStatus.Text +="Error:"+ a.Message +"<br />'; File: Data.xml <?xml version='1.0' encoding='utf-8' ?> <EmployeeDetails> <FirstName>ZAIDl</FirstName>
  • 12. )(ML 327 .:MiddleName>ZARl</MiddleName> <LastName>HAIDER~/LastName> <Emai11d>[email protected]</Emailld> .:Mobile>8898253962</Mobile> -=:Address>B/503, Jogeshwari , Mumbai</Address> <Blke>Yamaha FZS</Bike> </EmployeeDetails> File: Oata.xsd Open the existing XML. Go to XML menu. ·Select "Create schema"- option. Your XSD will be created automatically. <?xml version="1.0" encoding="utf-8"?> <xs:schema. attributeFormDefault="unqualified" xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:element name="EmployeeDetails"> <xs:complexType> <xs:sequence> <xs:element name="FirstName" type="xs:string" /> <xs:element name="MiddleName" type="xs:string" /> <xs:element name="LastName" type="xs:string" /> <xs:element name="Emailld" type="xs:string" /> <xs:element name="Mobile" type="xs:unsignedLong"/> <xs:element name="Address" type="xs:string" /> <xs:element name="Bike" type="xs:string" /> </xs:sequence> </xs:complexType> </xs:element> </xs:schema> t)l:s ·xMl,Display and:rrahsf-9~ 1''.lS elementFormDefault="qualified" Another standard associated with XML is XSL Transformations (XSL'I). XSLT allows you to create style sheets that can extract a portion of a large XML document or transform an XML document into another type of XML document. An even more popular use of XSLT is to convert an XML document into an HTML document that can be displayed in a browser. XSLT is easy to use from the point of view of the .NET class library. All you need to understand is how to create an XslCompiledTransform object (found in the Sys'tem.Xml.Xsl namespace). You use
  • 13. wuuJiq £ M%iiHMGPi+ its Load() method to specify a style sheet and its Transfonn() method to output the result to a fit srreant e or There are two main components in XSLT that helps transformations, XSLT Proces~o formatter. First, the XSLT processor takes two inputs, a XML document and a XSLT sty! r ~ nd XSL XSLTprocessor starts from the root node and then it goes for the root node's children. Th:s ;et. lbe searches the stylesheet element to see if any template element and other XSLT elements p ocessor As per the defined XSLT rules it fetches data from the XML document and generates a are! defined. . resu ts tr . XML formal The XML formatter takes mput as a result tree and generates the final end ee 111 HTML. text other XML format. products as The XML Web Control The XML control is used to display an XML document or the results ofan XSL Tra ti ns onn Note: At least one of the XML Document properties must be set or no XML doc · ument · displayed. ts . eoreit' You can also specify an XSLT document that will fonnat the XML document b ti written to the output. You can format the XML document with the Transfonn pro e 18 the TransfonnSource property. P rty or Example XML File: XMLFiJe.xml <?xml version='1.0" encoding='utf-8' ?> <breakfast_meru> <food> <name>Biriyani</name> <price>$10.60</price> <description>Rice with chicken</description> <calories>650</calories> </food> <food> <name>Juice</name> <price>$4.20</price> <description>Frult juices like mango, banana, apple</description> <calories>200</calories> </food> </breakfast menu>
  • 14. XML 329 XSLTFile XSLTFile.xslt '°:?xml version="1.0" encoding="iso-8859-1"?> 1 .... ' t 11;, <html xsl:version="1.0" xmlns="http://www.w3.org/1999/xhtml"> xmlns:xsl="http://www.w3.org/1999/XSL/Transform" <body style="font-family:Arial;font-size:12pt;background-color:#EEEEEE"> <xsl:for-each select="breakfast_menu/food"> <div style="background-color:teal;color:white;padding:4px"> <span style="font-weight:bold"> <xsl:value-of select="name"/> </span> - <xsl:value-of select="price"/> </div> <div style="margin-left:20px;margin-bottom:1em;font-size:1Opt"> <xsl:value-of select="description"/> <span style="font-style:italic"> <xsl:value-of select="calories"/> - (calories per serving) </span> </div> </xsl:for-each> </body> </html> .... Xmn I .., Use this <OfltnH to perfonn XSl trlmfonns. {' · • LaHI Webforml.aspx source code - ,e,• Without XML Control r. _,,•-·.r,• :,-.. "Xlxxl ... . ..'.'./'!,'./ <%@ Page Language="C#" lnherits="Webform1" %> AutoEventWlreup="true" CodeFile="Webform1.aspx.cs"
  • 15. --- <html xmlns="http:/Jwww.w3.org/1999/xhtml"> <head n1nat='server"> <ti11e></title> </head> <bOdy> <form ld='form1' n1nat=·server"> <div> <table class='style1'> <td class='style3'> dvancad Wab Prograrnrn1ng <asp:Button ID='Button1' n1nat="server" Font-Bold="True" Font-Size="Larger" ForeColor-"#003366' Height="33px" onclick="Button1_Click" styte='font-weight: 700" Text="XML Display" /> <ltd> <td> <asp:Button ID="Button2" n1nat="server" Font-Bold="True" Font-Size="Larger" ForeColor-"#003366" Height="33px" onclick="Button2_(?1ick' styte='font-weight: 700" Text='Without XML Control "/> <ltd> </tr> <td class='style6"> <asp:Xml ID="Xml1" runat="server"></asp:Xml> <ltd> <td class='style5"> <asp:Label ID="Label1" runat='server" Font-Bold="True" Font-Size="Large" I Text='Label"></asp:Label> <ltd> </tr> </table> </div> </form> </body> </html>
  • 16. )(ML + C' 1,) ©"' [ XML Display I Webforml.aspx.cs using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.IQ; using System.Xml; using System.Xml.Schema; using System.Xml.XPath; using System.Xml.Xsl; using System.Web.UI; using System.Text; using System.Web.UI.WebControls; public partial class Webform1 : System.Web.UI.Page { [ Without XML Control ] Label protected void Page_Load(object sender, EventArgs e) { protected void Button1_Click(object sender, EventArgs e) { XmI1.Visible = true; Label1 .Visible =false; // This is being read from the same folder as this page is in.(only for demo purpose) // In real applications this xml might be coming from some external source or database. string xmlString = File.ReadAIIText(Server.MapPath("XMLFile.xml")); II Define the contents of the XML control Xm11.DocumentContent =xmlString; II Specify the XSL file to be used for transformation. 331
  • 17. DD &l¼i,H+MW?i+Wi,,hm! Xml1 .TransformSource =Server.MapPath("XSLTFile.xslt"); } protected void Button2_Click(object sender, EventArgs e) { Xml1.Visible =false; Label1.Visible =true; JI Getting file path string strXSLTFile =Server.MapPath("XSLTFile.xslt"); string strXMLFile =Server.MapPath("XMLFile.xml"); II Creating XSLCompiled object XslCompiledTransform objXSLTransform = new XslCompiledTransform(); objXSLTransform.Load(strXSLTFile); II Creating StringBuilder object to hold html data and creates TextWriter object to hold data f XslCompiled.Transform method rom StringBuilder htrnlOu1put = new StringBuilder(); TextWriter htrnlWriter =new StringWriter(htmlOutput); II Creating XmlReader object to read XML content XmlReader reader= XmlReader.Create(strXMLFile); II Call Transform() method to create html string and write in TextWriter object. objXSLTransform.Transform(reader, null, htmlWriter); Label1.Text =htmlOutput.ToString(); // Closing xmlreader object reader.Close(); ,
  • 18. XML 333 1oe.n,o,t:614Z/Wtblorm1/Weblorn X + © IOCalnost:t,l '1 ® <:! Q . .. . . - ~---- - - l~ ~ r.l""'.~;. -.m•,.,.-_ _ ¼ ~,..,-i;:.· _ . '""'- ..,,. t;.... ....- .,. .,_,," _ ... • 1 ·• '" [!<ML Display I , [Without_ XML Control Biriyani - $10.60 Rice with chicken650 (calories per serving) Juice - $4.20 i1 Frurt juices like mango, banana, apple200 (calories per serving) loc,lloldlW#mforfflVWcllfo.-,· )( I ~.: C! 0 ~- f.XMl.;J}i~play Biriyani - $10.60 Rlct with _151),_,,.,-inw Juice - $4.20 FrultjulCIO 11<,-.bo111111, oppllm/-por-'"11/ ll!l@ - ·:i .'-:e;-z~-:~::.~:-~--~~~:.t~:f1~~~#~:@-:ii~~>r -:~/-.,;-~-~·:_ J ·:}J~~fflffY~-:~·-·:· I. Explain xml with example. 2. Explain XML TextWriter with example. 3. Explain XML TextReader with example. 4. How to Reading an XML Document? Explain with example. 5. Explain XML Validation with proper example. 6. Explain XML Display and Transforms in asp.net with example.