Consider the following XML snippet:
<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 key points here being that I can retrieve multiple
fields all at once, and in the order specified in the XPath statement (not
the order in the XML source).
The fields I'm after are all peers. There might be additional fields
(children of /top/date) that I'd want to ignore. The values need to be
concatenated without adding or removing whitespace, or removing leading
zeros.
Thanks in advance to those who answer, and to those who've answered my
previous questions.
--
Al Dunstan, Software Engineer
OptiMetrics, Inc.
3115 Professional Drive
Ann Arbor, MI 48104-5131
> <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/