Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 14th, 2005, 12:10 AM
Registered User
 
Join Date: Nov 2005
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default HTML for XSLT

 have an HTML file and I want to extract some content from it, using XSL and XPath Programming.

Following is the code format that is repeated throughout the html file in between tr tags of a table. I want to capture the data marked in bold. [ie., the URL, Event, Priority (High or Low) and the date in each such row of the table.

  <tr valign="top">
    <td class="class1">•</td>
    <td> <a href="link.html"> Event</a><br><b>High</b> (Tue, Nov 8)
   </td>
  </tr>

Following is my XSL code that I am using to simply get the Date and it is not working. Can you point out the mistake?

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
  <xsl:output method="html"/>

  <xsl:template match="/">
    <SellerFeedback>

    <xsl:for-each select="//tr[@valign='top']/td[@class='class1']/td/a/br/small/b/../../../../..">

    <xsl:sort select="/td/td/a/br/small/b/."/>
<Feedback>
     <Date><xsl:value-of select="/td/td/a/br/small/b/."/> </Date>
        </Feedback>
    </xsl:for-each>
    </SellerFeedback>
  </xsl:template>
</xsl:stylesheet>

Regards,
Tarun

 
Old November 14th, 2005, 11:29 PM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

select="//tr[@valign='top']/td[@class='class1']/td/a/br/small/b/../../../../..

There are two td elements in this path. I don't believe your source document has a td element that is a child of another td.

Also, don't go all the way down and then up again. Use predicates like

//tr[@valign='top'][td[...]/a/br/small/b]

which will select a tr element that has the relevant tree beneath it.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference





Similar Threads
Thread Thread Starter Forum Replies Last Post
strip html tags with xslt smiter XSLT 4 June 19th, 2012 08:34 AM
html to xml convertion using xslt moshaik BOOK: XSLT 2.0 and XPath 2.0 Programmer's Reference, 4th Edition ISBN: 978-0-470-19274-0 2 November 24th, 2008 10:33 AM
How can I take HTML content in XSLT? nadavvin XSLT 7 September 6th, 2006 09:18 AM
XSLT of an HTML data NEO1976 XSLT 3 July 5th, 2006 08:28 AM
Two HTML Tables and Two XSLT with Two XML? gman44 XSLT 1 March 1st, 2006 04:53 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.