xml image hyperlink production code

PHPz
Release: 2017-04-02 11:21:38
Original
3286 people have browsed it

Another problem encountered when studying, making imagesHyperlinkTo make Put the link address in the href attribute of , 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>
Copy after login

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>
Copy after login

The display result on the browser:
Display two pictures in vertical rows
Instructions:
To use hyperlinks, you need to use the two tags of and . 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}

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>
Copy after login

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!

source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!