开发者

Parsing some XML and need to GET last in the array or latest date. Having trouble

开发者 https://www.devze.com 2023-04-12 13:29 出处:网络
XML is here: http://www.treasury.gov/resource-center/data-chart-center/interest-rates/Datasets/ltcompositeindex.xml

XML is here: http://www.treasury.gov/resource-center/data-chart-center/interest-rates/Datasets/ltcompositeindex.xml

But I am using a proxy on my server, cross-domain/same-origin is not an issue.开发者_Python百科

It's organized by "Quote Date" and I need to get the most current rate which is always last, I think. Any idea for the best way to get it? A timestamp won't work because today's date could be a weekend or holiday. In this simplified example of the data I would only like to print,

"Date: 12-OCT-11, Rate: 2.87"

Thanks!

<G_QUOTE_DATE>
  <QUOTE_DATE>11-OCT-11</QUOTE_DATE>
  <RATE_TYPE>BC_20year</RATE_TYPE>
  <G_RATE>
    <RATE>1000.87</RATE>
  </G_RATE>
</G_QUOTE_DATE>
<G_QUOTE_DATE>
<QUOTE_DATE>12-OCT-11</QUOTE_DATE>
  <RATE_TYPE>BC_20year</RATE_TYPE>
  <G_RATE>
    <RATE>2.87</RATE>
  </G_RATE>
</G_QUOTE_DATE>


Try an XPath like this:

//QUOTE_DATE[last()]/G_RATE/RATE
0

精彩评论

暂无评论...
验证码 换一张
取 消