Professional Documents
Culture Documents
EXAMPLE:
<note>
<to>Medha</to>
<from>Vani</from>
<heading>It’s prachi’s birthday</heading>
<body>don’t forget to wish her</body>
</note>
XML HTML
Is designed to carry data-with Is designed to display data -
focus on what data is with focus on how data looks
Tags are not predefined (tags Tags are predefined
are invented by author of XML
document)
Explain is Extensible:
1. Most XML application will work as expected even if some
data is added or lost/removed
2. Is simplifies data sharing,transport,simplifies platform
changes,data availability
3. Sometimes data in computer is in incompatible form,
exchangeing such data may result in loss of some data. XML
stores data in plain text form, this provides a software and
hardware indep. Way of storing,sharing,transporting.
4. With XML data can be available to all kind of “reading
machines”
With a few lines of JavaScript code, you can read an XML file
and update the data content of any HTML page.
Uses of XML:
1. Day to day transactions:
Stocks and shares
Financial transcation
Medical data
Mathematical data
Scientific measurements
News infos
Weather services
2. XML news is a specification for exchanging news and other
infos.
3. <?xml version="1.0" encoding="UTF-8"?>
<nitf>
<head>
<title>Colombia Earthquake</title>
</head>
<body>
<headline>
<hl1>143 Dead in Colombia Earthquake</hl1>
</headline>
<byline>
<bytag>By Jared Kotler, Associated Press Writer</bytag>
</byline>
<dateline>
<location>Bogota, Colombia</location>
<date>Monday January 25 1999 7:28 ET</date>
</dateline>
</body>
</nitf>
4.
<root>
<child>
<subchild>……..</subchild>
</child>
</root>
XML Elements:
An element can contain text,attribute,other elements
XML elements are extensible? Yes bcos elements can be
extended to carry more information
XML Attributes:
1. Attributes are designed to contain data related to a specific
element
2. Must be quotes<person gender=”male”> single/doubl quote
XML Namespaces:
<h:table>
<h:tr>
<h:td>Apples</h:td>
<h:td>Bananas</h:td>
</h:tr>
</h:table>
<f:table>
<f:name>African Coffee Table</f:name>
<f:width>80</f:width>
<f:length>120</f:length>
</f:table>
Name conflicts:
Names are defined by developer, often things like this happens
when trying to mix XML documents from different applications.
<table> <table>
<tr> <name>African Coffee
<td>Apples</td> Table</name>
<td>Bananas</td> <width>80</width>
</tr> <length>120</length>
</table> </table>
<h:table>
<h:tr>
<h:td>Apples</h:td>
<h:td>Bananas</h:td>
</h:tr>
</h:table>
<f:table>
<f:name>African Coffee Table</f:name>
<f:width>80</f:width>
<f:length>120</f:length>
</f:table>
Here both tables have different meanings.
<h:table xmlns:h="http://www.w3.org/TR/html4/">
<h:tr>
<h:td>Apples</h:td>
<h:td>Bananas</h:td>
</h:tr>
</h:table>
<f:table xmlns:f="https://www.w3schools.com/furniture">
<f:name>African Coffee Table</f:name>
<f:width>80</f:width>
<f:length>120</f:length>
</f:table>
</root>
XSLT: is a lang that can be used to transform XML documents into other
formats.
xml into html
Displaying XMLs:
1. Raw XML files can be viewed in all major browsers.
<?xml version="1.0" encoding="UTF-8"?>
- <note>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>
XML HttpRequest:
All modern browsers have a built in XMLHttprequest object to
request data from server.
The XMLHttpRequest Object
The XMLHttpRequest object can be used to request data from a web
server.
if (window.XMLHttpRequest) {
// code for modern browsers
xmlhttp = new XMLHttpRequest();
} else {
// code for old IE browsers
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}