I\'m trying to parse a rss feed that looks like this for the attribute \"date\":
-
Think about using sequence comprehensions, too. They're useful for dealing with XML, particularly if you need complicated conditions.
For the simple case:
for {
c <- rssFeed \\ "@date"
} yield c
Gives you the date attribute from everything in rssFeed.
But if you want something more complex:
val rssFeed =
-
val sep = "\n----\n"
for {
channel <- rssFeed \ "channel"
item <- channel \ "item"
y <- item \ "c"
date <- y \ "@date" if (date text).equals("AA")
} yield {
val s = List(channel, item, y, date).mkString(sep)
println(s)
}
Gives you:
-
----
-
----
----
AA