开发者

XSL variable number of child nodes

I've got some XML elements with a number attached as more are avai开发者_如何学Pythonlable.

Such as this:

<Images>
    <Image1>C:\Path\To\AnImage</Image1>

    <Image2>C:\Path\To\AnotherImage</Image2>
</Images>

The amount of Images in each XML doc is variable. How can I make sure that my XSL file will show all elements inside the tag?

I also want to put each of the strings inside each ImageX tag inside a Img src="stringfromxmlelement" with XSL? Is this possible?

Tony


<xsl:template match="Images/*[starts-with(name(),'Image']">
<img src="{.}" />
</xsl:template>

BTW, perhaps you can't change the XML tag names, but it would better to name the inner tags as Image rather than ImageX, which is probably unneccesary.


I'd try something along these lines:

<xsl:template match="Images">
  <xsl:for-each select="*">
    <img src="{text()}" />
  </xsl:for-each>
</xsl:template>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜