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 May 25th, 2007, 11:02 AM
Authorized User
 
Join Date: May 2007
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default how to find text within range of two tags

hi!
    I am trying to find a way to detect a text within two tags.
i need to grab text within <br/>..<p>text start with BACKGROUND
is any one can help on this ?
input xhtml file:
<br />OBJECTIVES: The purpose of this study was to assess the impact of body mass <sup></sup>index (BMI) on the short- and long-term
outcomes after percutaneous <sup></sup>coronary intervention (PCI).
<sup></sup>

<p>BACKGROUND: Obesity is associated with advanced coronary artery
disease <sup></sup>(CAD). However, the relation between BMI and
outcome after PCI <sup></sup>remains controversial. <sup></sup></p>

 
Old May 25th, 2007, 11:09 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

Something like

<xsl:template match="text()[starts-with('OBJECTIVES')][preceding-sibling::*[1][self::br]]">

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
 
Old May 25th, 2007, 04:13 PM
Authorized User
 
Join Date: May 2007
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default

thanks
but Can you please explain me how it works ?

komal


 
Old May 25th, 2007, 04:27 PM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

text()

matches a text node

[starts-with('OBJECTIVES')]

the string value of the text node must start with "OBJECTIVES"

[preceding-sibling::*

there must be a preceding sibling

[1]

that is the first preceding sibling

[self::br]]

and that is a br element

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
VBA Macro FIND THIS MONTH in a given range mvatoi Excel VBA 3 August 24th, 2007 08:12 AM
find days per month in a date range rojer MySQL 1 June 5th, 2007 07:36 PM
find name and define range for Column qball Excel VBA 4 November 17th, 2004 03:55 PM
Extracting text between tags aware Classic ASP Professional 4 December 24th, 2003 04:25 AM
Regular Expression to find all tags except bold edwardforgacs C# 0 December 23rd, 2003 09:31 AM





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