DISPLAY XML DATA ON A WEBPAGE WITHOUT PARSING

The XML stands for Extensible Markup Language. XML is a format for organizing data using tags that define elements and attributes. It’s readable by both humans and machines, ideal for structuring information in web services, configuration files, and data interchange formats due to its simplicity and flexibility in representing hierarchical data structures .In order to display the XML datas in a webpage it can be done by creating an xml file then parsing it using Javascript.  A simple XML file can be created by using the extension .xml . This is one way of creating and displaying a file.

There is another method to showcase an XML file without parsing it using javascript.

you can place the xml data inside of the <pre> tag in html .This tag helps from formatting. The tags are modified as &lt; for < and &gt; for  > . These symbols are used inside of the HTML tag so that the compiler will not be confused between the tags of the HTML and the tags of the XML.

Now let us create a small simple XML code to display it into the web page.

<school>
 <student>
  <rollno>01</rollno>
  <name>tamizh</name>
  <age>16</age>
  <group>biology</group>
 </student>
 <student>
  <rollno>02</rollno>
  <name>kayal</name>
  <age>16</age>
  <group>commerce</group>
 </student>
 <student>
   <rollno>03</rollno>
   <name>pughazh</name>
   <age>17</age>
   <group>biology</group>
  </student>
</school>

This is a simple XML program with school database now let us  combine it with html and display it in a webpage.

<html>
<head>
<title>
XML Data on a webpage
</title>
</head>
<body>
<h1>students and their groups</h1>
<pre>
&lt;school&gt;
 &lt;student&gt;
  &lt;rollno&gt; 01 &lt;/rollno&gt; 
  &lt;name&gt; tamizh &lt;/name&gt;
  &lt;age&gt; 16 &lt;/age&gt;
  &lt;group&gt; biology &lt;/group&gt;
 &lt;/student&gt; 
 &lt;student&gt; 
  &lt;rollno&gt; 02 &lt;/rollno&gt;
  &lt;name&gt; kayal &lt;/name&gt;
  &lt;age&gt; 16 &lt;/age&gt;
  &lt;group&gt; commerce &lt;/group&gt;
 &lt;/student&gt;
 &lt;student&gt;
  &lt;rollno&gt; 03 &lt;/rollno&gt;
  &lt;name&gt; pughazh &lt;/name&gt;
  &lt;age&gt; 17 &lt;/age&gt;
  &lt;group&gt; biology &lt;/group&gt;
 &lt;/student&gt;
&lt;/school&gt;
</pre>
</body>
</html>

Thus a XML data can be displayed in a webpage using HTML.

 

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top