xsl-list
[Top] [All Lists]

Re: [xsl] XPath to get node with sons with specific text

2009-08-10 05:06:38
Use

Contact[contains(Name,'test1')]

Depending on where ever your context node is.


 
-------Original Message------- 
 
From: Andy Kohn 
Date: 8/10/2009 9:34:48 AM 
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com 
Subject: [xsl] XPath to get node with sons with specific text 
 
Using XPath, is it possible for me to select a whole branch by 
Searching for the first child to contain some specific text. 
 
For example for the following XML: 
 
<List> 
<Contact> 
<Name>test1test</Test> 
<Data>sample data</Data> 
<Data>sample</Data> 
<Data>sample 123</Data> 
</Contact> 
<Contact> 
<Name>test133</Test> 
<Data>sample data</Data> 
</Contact> 
<Contact> 
<Name>test2test</Test> 
<Data>sample data</Data> 
<Data>sample</Data> 
<Data>sample 123</Data> 
</Contact> 
</List> 
 
If I search for "test1" I want from the Xpath to return the first 
<Contact> and the second <Contact>, including all child nodes (<Name> 
And <Data>): 
 
<Contact> 
<Name>test1test</Test> 
<Data>sample data</Data> 
<Data>sample</Data> 
<Data>sample 123</Data> 
</Contact> 
<Contact> 
<Name>test133</Test> 
<Data>sample data</Data> 
</Contact> 
 
Something like: 
//Name[contains(.,'Ab')] 
But this returns only the Name node, and not all the childs. 
 
Thanks, 
 
Andy. 
 
--~------------------------------------------------------------------ 
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list 
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/ 
Or e-mail: 
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com> 
--~-- 
 

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>