PDA

View Full Version : Can I use XPath and XSLT to extract an address?


darkmage784
09-02-2005, 08:55 PM
I am learning XML, and I was wondering if it was possible to use <xsl:value-of> to select a URI. e.g.:

<!-- ... -->
<favouriteWebsiteList>
<website>
<address>http://www.codingforums.com</address>
<name>Coding Forums</name>
</website>
<website>
<address>http://www.w3schools.com</address>
<name>W3Schools</name>
</website>
<!-- ... -->
</favouriteWebsiteList>

And use this XSLT to transform it:

<!-- ... -->
<xsl:for-each select="//favouriteWebsiteList/website">
<a href="<xsl:value-of select='address' />"><xsl:value-of select="name" /></a>
</xsl>

I get a "not well formed" error at the red text.

Does anyone know a way to do this?

CrzySdrs
09-02-2005, 10:01 PM
<xsl:for-each select="//favouriteWebsiteList/website">
<a href="{address}"><xsl:value-of select="name" /></a>
</xsl>


I beleive that should work, but if I am wrong... I know that this works:


<xsl:for-each select="//favouriteWebsiteList/website">
<xsl:variable select="address" name="addy" />
<a href="{$addy}"><xsl:value-of select="name" /></a>
</xsl>