Home  >  Article  >  Backend Development  >  xml image hyperlink production code

xml image hyperlink production code

PHPz
PHPzOriginal
2017-04-02 11:21:383336browse

Another problem encountered when studying, making imagesHyperlinkTo make Put the link address in the href attribute of 3499910bf9dac5ae3c52d5ede7383485, but this means putting tags within tags, which is not allowed. I checked the "Web Programming Practical Tutorial" and found out the correct solution. Now I will share it with you. This code requires two images: a.gif and b.gif.

This code requires two images: a.gif and b.gif
my. xml
The following content is the program code:

<?xml version="1.0" encoding="GB2312"?>
<?xml-stylesheet type="text/xsl" href="mystyle.xsl"?>
<Books>
<Book ID="a001">
<Name>网络指南</Name>
<Photo>a.gif</Photo>
<Homepage>http://www.a.com</Homepage>
</Book>
<Book ID="a002">
<Name>局域网技术</Name>
<Photo>b.gif</Photo>
<Homepage>http://www.b.com</Homepage>
</Book>
</Books>

mystyle.xsl
The following content is the program code:

<?xml version="1.0" encoding="GB2312"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="Books/Book">
<xsl:element name="a">
<xsl:attribute name="href">
<xsl:value-of select="./Homepage"/>
</xsl:attribute>
<xsl:element name="img">
<xsl:attribute name="src">
<xsl:value-of select="./Photo"/>
</xsl:attribute>
</xsl:element>
</xsl:element>
<br/>
</xsl:template>
</xsl:stylesheet>

The display result on the browser:
Display two pictures in vertical rows
Instructions:
To use hyperlinks, you need to use the two tags of 2421aaa7178ab6b73905a4fbcc7cad2d and 6b5cc95b93d4c0ebbef8f3c279f25847. For basic usage, please refer to the above. The example is a little more profound. If you come up with it, remember to share it with everyone.
Long experience, hey, this is the first time I have seen it.
{Homepage}
a2b598042c6cfa71f531c45f68a6e8cc
Are the two equivalent at any time?
The code above is slightly different from my original effect. Let me help you improve it:

mystyle.xsl
<?xml version="1.0" encoding="GB2312"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="Books/Book">
<a href="{Homepage}">
<img src="{Photo}"/>
</a>
</xsl:template>
</xsl:stylesheet>

The above is the detailed content of xml image hyperlink production code. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn