comp.text.xml
[Top] [All Lists]

Re: Selecting multiple fields, out of order, in a single Java XPath expr

Subject: Re: Selecting multiple fields, out of order, in a single Java XPath expression
From: Martin Honnen
Date: Fri, 18 Jul 2008 18:11:07 +0200
Newsgroups: comp.text.xml


A. W. Dunstan wrote:

<top>
  <date>
    <year>2008</year>
    <month>07</month>
    <day>18</day>
  <date>
</top>

I'd like to do something like this (in Java):

  String date = anXPathObject.evaluate("/top/date/[day,month,year]", doc);

and wind up with date having a value of "18072008".  The "[day,month,year]"
(or whatever the syntax is) would tell XPath 'I
want /top/date/day, /top/date/month and /top/date/year extracted and
concatenated'.

The XPath expression is
  concat(/top/date/day, /top/date/month, /top/date/year)

--

        Martin Honnen
        http://JavaScript.FAQTs.com/

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