S No. | HTML | XML |
---|---|---|
1 | HTML is used to display data and focuses on how data looks. | XML is a software and hardware independent tool used to transport and store data. It focuses on what data is. |
2 | HTML is a markup language itself. | XML provides a framework to define markup languages. |
3 | HTML is not case sensitive. | XML is case sensitive. |
4 | HTML is a presentation language. | XML is neither a presentation language nor a programming language. |
<?xml version=”1.1” encoding=”|ISO-8859-1|”?>
<price>15.30</price>
<bookstore>
<book category="children">
<title>Shiva</title>
<author>Ram</author>
<year>2019</year>
<price>15.30</price>
</book>
<book category="web">
<title>Learning XML</title>
<author>Narayan</author>
<year>2021</year>
<price>19.90</price>
</book>
</bookstore>
<title>, <author>, <year>,
and <price>
have text content because they contain text (like 15.30).<bookstore>
and <book>
have element contents, because they contain elements.<book>
has an attribute (category="children").<element></element>
<element />
< and >
are illegal in XML elements. CDATA section starts with <![CDATA[“ and end with “]]>
. address.xml#pointer(/ descendant ::streetnumber[@id =9])
<?xmlversion="1.0" encoding ="UTF-8">​
Document Type Declaration<!DOCTYPE library PUBLIC="-//DTDLibrary//EN" "path/of/library.dtd">​
XML Body<library>
<title>Free Time Learn</title>
<heading>Reminder</heading>
<body>XML Tutorial</body>
</library>
<?php
$XML=simpleXML_Load_file(“saleslist.XML”) or die(“Error: cannot create object”);
for ($x=0; $x<6; $x++)
echo $XML — > book[$x] — > title[‘bookname’] . “<br>”;
?>
saleslist.XML
– is the name of the file we are calling using PHP.<person gender=”female”> or <person gender=’male’>
<flower name=”lotus” ‘rose’ ‘lily’>
Imports System.Xml
using System.Xml;
<![CDATA[
Within this Character Data block I can
use double dashes as much as I want (along with <, &, ', and ")
*and* %MyParamEntity; will be expanded to the text
"Has been expanded" ... however, I can't use
the CEND sequence. If I need to use CEND I must escape one of the
brackets or the greater-than sign using concatenated CDATA sections.
]]>
<description>An example of escaped CENDs</description>
<!-- This text contains a CEND ]]> -->
<!-- In this first case we put the ]] at the end of the first CDATA block
and the > in the second CDATA block -->
<data><![CDATA[This text contains a CEND ]]]]><![CDATA[>]]></data>
<!-- In this second case we put a ] at the end of the first CDATA block
and the ]> in the second CDATA block -->
<alternative><![CDATA[This text contains a CEND ]]]><![CDATA[]>]]></alternative>
var xhttp= newXML Httprequest();
Xhttp.onreadystatechange=function();
{ If this.readystate==4&& this.status==200)
{ Action to be performed when document is ready;
Document.getelementbyID(“Demo”)
Innerhtml=xhttp.responseText;}};
<person>
<name>Ramana</name>
<age>31</age>
<homecity>
<name>India</name>
<lat>123.024</lat>
<long>120.010</long>
</homecity>
</person>
<personxml:person xmlns:personxml="https://www.freetimelearning.com/xml/person"
xmlns:cityxml="http://www.freetimelearn.com/xml/cities">
<personxml:name>Ramana</personxml:name>
<personxml:age>31</personxml:age>
<cityxml:homecity>
<cityxml:name>India</cityxml:name>
<cityxml:lat>123.024</cityxml:lat>
<cityxml:long>120.010</cityxml:long>
</cityxml:homecity>
</personxml:person>
personxml:
are tags belonging to your XML, all the ones that start with cityxml:
are mine.XML 1.0
Recommendation. The definition says: "Processing instructions (PIs) allow documents to contain instructions for applications… PIs are not part of the document's character data, but MUST be passed through to the application."<?target instructions?>
<?display table-view?>
<?sort alpha-ascending?>
<?textinfo whitespace is allowed ?>
<?elementnames <fred>, <bert>, <harry> ?>
<?xml-stylesheet href="style.css" type="text/css"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc>https://www.freetimelearning.com/</loc>
<lastmod>2017-10-04T22:37:13+00:00</lastmod>
<changefreq>weekly</changefreq>
<priority>1.0</priority>
</url>
</urlset>
<foo if{DB}="A">bar</foo>
<xsl:if test="@foo=’bar’">
<xsl:text>Hello, world!</xsl:text>
</xsl:if>