Tôi muốn xem viết lại tập lệnh dưới đây bằng cách sử dụng http://anti-xml.org thay vì Scala XML.Ví dụ về xử lý xml nhưng sử dụng anti-xml thay vì Scala xml
Đây là một đoạn trích từ Chương 10 Herding XML trong Scala - http://ofps.oreilly.com/titles/9780596155957/HerdingXMLInScalaDSLs.html
// code-examples/XML/reading/pattern-matching-script.scala
import scala.xml._
val someXML =
<sammich>
<bread>wheat</bread>
<meat>salami</meat>
<condiments>
<condiment expired="true">mayo</condiment>
<condiment expired="false">mustard</condiment>
</condiments>
</sammich>
someXML match {
case <sammich>{ingredients @ _*}</sammich> => {
for (cond @ <condiments>{_*}</condiments> <- ingredients)
println("condiments: " + cond.text)
}
}
Cảm ơn
Một chút muộn nhưng ... cảm ơn! – Rodolfo
Trong anti-xml 0.3 và sau đó, [\\ không di chuyển theo thứ tự độ sâu đầu tiên] (https://github.com/djspiewak/anti-xml/issues/49), vì vậy 'condiments \\ text' hiện hoạt động tốt . – Steve