Jump to content

question


jian_xin85

Recommended Posts

i need help :how do i print a attribute "isbn" from BOOK????<?xml version="1.0"?><?xml-stylesheet type="text/xsl" href="Lab8_1.xsl "?><INVENTORY> tis line----> <Book code="A-9801" Isbn="0-12-960162-7"> <title>XML By Example</title> <author>Sean McGrath</author> <Publisher>Prentice Hall</Publisher> <Year>1998</Year> <Description> Covers keys e-commerce initiatives <br/> <![CDATA[<CDROM>inlcuded.]]> <br/> </Description> </Book></INVENTORY>thanz i n advance

Link to comment
Share on other sites

Generally, attributes shouldn't contain data that should be extracted. If you are the creator of the XML (or have a connection with the one), you should (tell him to) place the attributes in other elements.The way to get an attribute is the same as an element but the XPath expression is different.Try this:

<?xml version="1.0" encoding="UTF-8"?><xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><xsl:template match="/">      <xsl:value-of select="/INVENTORY/Book/@Isbn"/></xsl:template></xsl:stylesheet>

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...