Suppose I have an XML and map
val xml =
<a>
<b x="x1" y="y1"/>
<b x="x2" y="y2"/>
<b x="x3" y="y3"/>
</a>
val m = Map("x1" -> "y1", "x2" -> "y2", "x3" -> "y3")
I am fetching <b> elements from XML and checking if the elements contain x and y attributes as in the map m.
val bs = xml \\ "b"
((bs \\ "@x").map(_.text) zip (bs \\ "@y").map(_.text)).toSet == m.toSet
Does it make sense ? How would you fix/improve this code ?
No comments:
Post a Comment