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 July 23rd, 2014, 03:22 PM
Registered User
 
Join Date: Jul 2014
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Extracting text from CDATA section of XML using XSL

Hi there

I'm not a programmer, but need some help to find a way of displaying text in the CDATA section of an XML file using XSL. Or if there is an alternative to using XSL then I'm all ears (eyes?). Take, for example, the following line of my XML file:

Code:
<property id="instruction1" media="screen"><![CDATA[<p>Select the <span class="bold">option</span> you think is correct.</p>]]></property>
I ONLY want to display the text between the 'p' tags, i.e. "Select the option you think is correct." The formatting 'span' tag can be included if necessary, just as long as the 'p' tags are not displayed.

Is this possible?

I can post more/all of the XML code if required.

Thanks a lot
Niall
 
Old July 23rd, 2014, 04:22 PM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

The ting is the text that is in the CDATA element is just that, text. It might look like XML to you, but it doesn't to the XML processor (whether that is an XSLT one or not).

So you basically need some way of to load the text and process it again. You can't do this with standard XSLT.

Depending on what XSLT processor you are using it may have extension method you could call which you pass in the text and return a new node (assuming the text is a valid XML fragment) or the ability to write extension methods in another programming language (Java, C# etc).
__________________
/- Sam Judson : Wrox Technical Editor -/

Think before you post: What have you tried?





Similar Threads
Thread Thread Starter Forum Replies Last Post
xml copy with text substitution from map P2: problem with text outside CDATA mancocapac XSLT 0 January 16th, 2012 03:49 PM
cdata section elements and version in xsl:output bsridharg XSLT 1 July 7th, 2010 05:39 PM
How to strip out the CDATA from xml using xsl transformations XSLUSer XML 3 April 23rd, 2009 01:01 PM
Add a CDATA section; add nodeset to CDATA section kssudhish XSLT 3 January 3rd, 2008 07:13 AM
cdata-section-elements in xsl:output ROCXY XSLT 1 March 2nd, 2006 11:44 AM





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