Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

XSL, getting values from XML elements

Status
Not open for further replies.

birney29

Programmer
Oct 11, 2001
140
GB
For some reson the values "Name , Job" ect, in my xml document wont print out on the screen using this XSL file. It cant find the values. am i navigating the nodes wrongly? the files ar below :


*********XML********

<?xml version=&quot;1.0&quot; standalone = &quot;yes&quot;?>
<?xml-stylesheet type=&quot;text/xsl&quot; href=&quot;UIConfigStyle.xsl&quot; ?>
<data>
<Person>
<Name> Kenny Birney </Name>
<Job> Programmer </Job>
<Details> This data has been transformed into HTML through xsl and formatted through JavaScript and xml </Details>
</Person>
</data>

********XSL*********

<?xml version=&quot;1.0&quot;?>
<xsl:stylesheet version = &quot;1.0&quot; xmlns:xsl=&quot;<xsl:eek:utput method=&quot;html&quot;/>

<xsl:template match=&quot;/&quot;>
<html>
<head>
<title> Formatted data through xsl, 2 xml documents and Javascript </title>
</head>
<body onload = &quot;init()&quot; id=&quot;body&quot;>

<SCRIPT LANGUAGE=&quot;javascript&quot;>
function init()
{
testXML.async = false;
testXML.load(&quot;./ui.xml&quot;);

formatUI(testXML);
}

function formatUI(testXML)
{
i = 0;
itemElement = testXML.documentElement.childNodes.item(i);
document.bgColor = itemElement.childNodes.item(0).childNodes.item(0).nodeValue;
document.fgColor = itemElement.childNodes.item(1).childNodes.item(0).nodeValue;
document.all.body.style.fontSize= itemElement.childNodes.item(2).childNodes.item(0).nodeValue;
}

</SCRIPT>

<xsl:for-each select=&quot;data/Person&quot;>
<H1> <xsl:value-of select = &quot;.//Name&quot;/> </H1>
<xsl:value-of select = &quot;Job&quot; />
<p> <xsl:value-of select = &quot;Details&quot;/> </p>
</xsl:for-each>

</body>

<XML ID=&quot;testXML&quot;>
</XML>

</html>
</xsl:template>




</xsl:stylesheet>

Thanks!
 
Hi,

Your path to the name elemt eof your document is not correct it should read

<xsl:value-of select=&quot;Name&quot;></xsl:value-of>

The rest of it seems OK

B-)


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top