[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: XPath statement required pls

Subject: Re: XPath statement required pls
From: Adam Turoff <ziggy@xxxxxxxxx>
Date: Mon, 13 Aug 2001 14:02:00 -0400
get all attribute values xpath
On Mon, Aug 13, 2001 at 01:44:04PM -0400, Sanjay Pandey/Towers Perrin wrote:
> 
> Hi,
> 
> I have XML file as follows:
> <parameter name = "one">
>    <level1>
>       <level2 name = "a">
>      <level3>
>           <theField>something</theField>
>      </level3>
>       </level2>
>       <level2 name = "b">
>      <level3>
>           <theField>something</theField>
>      </level3>
>       </level2>
>       <level2 name = "c">
>      <level3>
>           <theField>something</theField>
>      </level3>
>       </level2>
>    </level1>
> </parameter>
> 
> <parameter name = "two">
> </parameter>
> 
> My problem is as follows:
> 1. I need to get all the occurrances of <theField> (... and that is fine, I
> am getting those, using XPathAPI, into a NodeIterator)

//theField

Find all occurances of <theField>.

> 2. For each field I want to get the nearest Attribute value, so that I can
> uniquely identify <theField>. Is there a generic way to get the
>      nearest Attribute value? In my case it is not always true that the
> attribute for a field (in this case <theField>) is at a particular level
>      (in the current case, I can get the attribute value by going w levels
> up, ... but then that is what I am trying to find if there is generic
>       way to find the nearest Attribute value for a particular field)

//theField/ancestor::*[@name][1]/@name

Find all occurrances of <theField>, then the first ancestor with a name
attribute, then that name attribute.

HTH,

Z.


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.