How XML is used on Server

In this article I have described that how XML application is used on server with the help of example.
  • 2057

XML Server

XML file can be save or store on the web server same as HTML file. Because it is plain text file as Html. XML can be generated on the server.  For generate on server its not require to any plug-in and not any software. XML can easily be stored and generated by a standard web server.

Example

A simple XML file.

<?xml version="1.0" encoding="ISO-8859-1"?>
<note>
  <Name>Shayam</Name>
  <add>Delhi</add>
  <message>Hello how are you</message>
</note>

Store XML file on the web server with ASP. Net

response.ContentType="text/xml"
response.Write("<?xml version='1.0' encoding='ISO-8859-1'?>")
response.Write("<note>")
response.Write("<Name>Shayam</Name>")
response.Write("<add>Delhi</add>")
response.Write("<message>Hello how are you</message>")
response.Write("</note>")

 We can also store XML file on the web server with XSLT style sheet

'Load XML file
set xml = Server.CreateObject("Test.XMLDOM")
xml.async = false
xml.load(Server.MapPath("demo.xml"))

'Load XSL file
set xsl = Server.CreateObject("Test.XMLDOM")
xsl.async = false
xsl.load(Server.MapPath("demo.xsl"))

'Transform XML file
Response.Write(xml.transformNode(xsl))

In this Example

  • The first part of XML code creates an instance of the Test XML parser (XMLDOM), and loads the XML Document into memory.
  • The second part of XML code creates another instance of the parser and loads the XSL Document into memory.
  • The last part of XML code transforms the XML document using the XSL document and sends the result as XHTML to your browser.

 

Further Readings

You may also want to read these related articles :here

Ask Your Question 

Got a programming related question? You may want to post your question here

Programming Answers here

© 2020 DotNetHeaven. All rights reserved.