代碼
創建一個小例子。
val foo = <foo><bar type="greet" date="2015-01-01T01:00:00.000">hi</bar>
<bar date="2012-01-01T01:00:00.000" type="count">1</bar>
<bar date="2014-01-01T01:00:00.000" type="color">yellow</bar>
</foo>
val bars = foo \ "bar"
bars.filter(s => (s \ "@date").exists(t => t.text > "2013-01-01T01:00:00.000")).map(u => (u \ "@type").text)
首先從foo中提取所有條,然後過濾日期並映射到類型。
輸出
List(greet, color)
代碼
所以對你來說應該是類似
val names = userElems.filter(s => (s \ "@CreationDate").exists(t => t.text > "2013-01-01T01:00:00.000")).map(u => (u \ "@DisplayName").text)
的代碼工作。謝謝 –
@VSriSandeep你能接受我的回答嗎?謝謝? – Kordi