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 January 11th, 2012, 12:42 PM
Authorized User
 
Join Date: Jul 2010
Posts: 74
Thanks: 23
Thanked 0 Times in 0 Posts
Question How to get part of the element value

This element is a sentence, formated as "CONFIRMATION XXX HAS BEEN CANCELLED", the "XXX" is a variable, including numbers and letters. I only want to get the "XXX" part. How can I do that?

The input XML file:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<return>
  <response1>CONFIRMATION 12345A HAS BEEN CANCELLED</response1>
  <response2>CONFIRMATION B654321 HAS BEEN CANCELLED</response>
</return>
The output XML file should like:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<return>
  <r1>12345A</r1>
  <r2>B654321</r2>
<return>
Using XSLT 1.0 version.

Thank you in advance.
 
Old January 11th, 2012, 12:47 PM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

You'll want to either use the substring() function or the substring-after() and substring-before() functions.

http://www.w3schools.com/xpath/xpath...ons.asp#string
__________________
/- Sam Judson : Wrox Technical Editor -/

Think before you post: What have you tried?
The Following User Says Thank You to samjudson For This Useful Post:
JohnKiller (January 11th, 2012)
 
Old January 11th, 2012, 01:03 PM
Authorized User
 
Join Date: Jul 2010
Posts: 74
Thanks: 23
Thanked 0 Times in 0 Posts
Default

Thanks, I only knew substring() fuctin before. And these another two function are Very useful.

Thank you, Sam.

Quote:
Originally Posted by samjudson View Post
You'll want to either use the substring() function or the substring-after() and substring-before() functions.

http://www.w3schools.com/xpath/xpath...ons.asp#string





Similar Threads
Thread Thread Starter Forum Replies Last Post
Identify element based on the element data/content ROCXY XSLT 7 September 8th, 2011 02:48 AM
Adding a web part to a SharePoint web part page sawanjc BOOK: Beginning SharePoint 2007: Building Team Solutions with MOSS 2007 ISBN: 978-0-470-12449-9 0 July 15th, 2011 04:37 PM
How to MOVE sub-element to preceding-sibling’s last sub-element lkd XSLT 6 March 15th, 2011 11:15 AM
Chapter 9: Element[user control] is not a known element Arya BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 2 December 20th, 2009 07:31 AM
Problem adding element to the previous element dani1 XSLT 5 September 10th, 2008 01:38 AM





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