Forum Moderators: open
1) How do I grab the info in this XML file (below) and make them all into HTML A HREF links in XSL?
<navLinks>
<link title="Home">index.html</link>
<link title="View all our products">products.html</link>
<link title="About our company">about.html</link>
<link title="Contact Us">contact.html</link>
</navLinks>
This is what I had (and nothing showed):
<xsl:for-each select="myPage/navLinks">
<a href="test.html"><xsl:value-of select="title"/></a>
</xsl:for-each>
2) I have 6 paragraphs of text in an XML document that goes like this:
<data>
<item>Paragraph 1 ... </item>
<item>Paragraph 2 ... </item>
<item>Paragraph 3 ... </item>
<item>Paragraph 4 ... </item>
<item>Paragraph 5 ... </item>
<item>Paragraph 6 ... </item>
</data>
I tried to use this loop, but it only produced the first paragraph.
<xsl:for-each select="//data">
<p><xsl:value-of select="//item"/></p>
</xsl:for-each>
Thanks for anyones assistance.
Thanks for the suggestion:
<xsl:for-each select="//data">
<p><xsl:value-of select="./item"/></p>
</xsl:for-each>
but, it still only grabs the first paragraph only. I actually tried using only a . as in
<xsl:for-each select="//data">
<p><xsl:value-of select="."/></p>
</xsl:for-each>
Thhis grabs all of them, but without any breaks. Maybe I could this with CSS?
<xsl:for-each select="myPage/content/data/item">
<p><xsl:value-of select="."/></p>
</xsl:for-each>
Thanks to mikesmith.
One issue however goes to the creation of links with the following XML example data:
<navLinks>
<link title="Home">index.html</link>
<link title="View all our products">products.html</link>
</navLinks>
I have used:
<xsl:for-each select="myPage/navLinks/link">
<a href="{@title}"><xsl:value-of select="."/></a><br/>
</xsl:for-each>
but it produces the links underlined and the link goes to the name or title:
index.html
products.html
about.html
contact.html
How can I grab the title and reverse the two?
<data>
<item>Paragraph 1 ... </item>
<item>Paragraph 2 ... </item>
<item>Paragraph 3 ... </item>
</data>
<data>
<item>Paragraph 1 ... </item>
<item>Paragraph 2 ... </item>
</data>
is this valid in your document?