سؤال

I have a requirement where I need the latest date from the XML below. In Xpath 2.0, there is function called max(). But am using Xpath1.0.

<Info><Date>2014-04-21</Date></Info><Info><Date>2014-05-05</Date></Info><Info><Date>2014-04-28</Date></Info>

Expected Output: 05/05/2014(dd/mm/yyyy)

Any inputs ??

هل كانت مفيدة؟

المحلول

Actually there is small change in my xml. The following is my XML(extra parent node is added).

<CustomContent>
<Info>
<Name>abc</Name>
<Date>2014-04-21</Date>
</Info>
<Info>
<Name>def</Name>
<Date>2014-05-05</Date>
</Info>
<Info>
<Name>ghi</Name>
<Date>2014-04-28</Date>
</Info>
</CustomContent>

Now here is the Xpath to find the max date for the above XML.

//CustomContent/Info/Date[not(text() <= preceding::Date/text()) and not(text() <=following::Date/text
())]/text()

Thanks everyone :)

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top