|
|
I'm trying to extract several fields from a Document, and it'd be nice if I
could get all of them at once. I need them in a specific order, however,
which is not the order they're in in the source Document. I _can_ extract
each one individually & concatenate, but I'm curious as to if/how this can
be done.
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
|
|