Jump to content

Help


YkH

Recommended Posts

Hi every body,Am a new user to this great fourm, as well as to Extensible Markup Language. Actually, I would like some body to show me the way of creating a simple web page using only and only Xml codes. I will be appretiated.

Link to comment
Share on other sites

Welcome to the forum. Even though XML is intended for use as storage as well as transfer of data between dissimiliar systems, you can transform it in a variety of ways to produce Web pages.There are several ways of transforming, you could use an XMLDOM model (hard to do) or a language designed for this purpose, such as XSLT (much easier). Both rely heavily on XPATH. So this should be your first step.Heres a quick example to create a web page using XML Data islands for both the XML and XSLT and using the MSXML 4.0 parser to transform.

<html>	<head>	<xml id="xmlSource">		<data>			<Member>				<Name>John Doe</Name>				<EmailAddress>JDoe@JDoe.Com</EmailAddress>			</Member>			<Member>				<Name>John Deer</Name>				<EmailAddress>JDeer@JDeer.Com</EmailAddress>			</Member>		</data>	</xml>	<xml id="xslStyle">		<xsl:stylesheet			xmlns:xsl="http://www.w3.org/1999/XSL/Transform"			xmlns:msxsl="urn:schemas-microsoft-com:xslt"			version="1.0">			<xsl:output method="html" />			<xsl:template match="/">				<xsl:for-each select="//Member">					<h3><xsl:value-of select="Name"/><xsl:text>-</xsl:text><xsl:value-of select="EmailAddress"/></h3>				</xsl:for-each>			</xsl:template>		</xsl:stylesheet>	</xml>		<script type="text/javascript">			function loadXML()			{				var xmlDoc   =	 new ActiveXObject("Msxml2.DOMDocument.4.0")				xmlDoc.async=false;				xmlDoc.loadXML(xmlSource.xml);				var xslSource   =	 new ActiveXObject("Msxml2.FreeThreadedDOMDocument.4.0")				xslSource.async=false;				xslSource.loadXML(xslStyle.xml);				xslSource.setProperty("SelectionNamespaces", "xmlns:xsl='http://www.w3.org/1999/XSL/Transform'")				var objTransformer	=	new ActiveXObject("Msxml2.XSLTemplate.4.0")				objTransformer.stylesheet = xslSource.documentElement				var objProcessor = objTransformer.createProcessor()				objProcessor.input = xmlDoc				objProcessor.transform()				document.write(objProcessor.output)			}		</script>	</head>	<body onload="loadXML()">	</body></html>

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...