For an XML fragment like this:
val fruits =
<fruits>
<fruit>
<name>apple</name>
<taste>red</taste>
</fruit>
<fruit>
<name>banana</name>
<taste>yellow</taste>
</fruit>
<fruit>
<name>banana</name>
<taste>green</taste>
</fruit>
<fruit>
<name>apple</name>
<taste>green</taste>
</fruit>
</fruits>
do something like:
fruits \\ "fruit"
returns a sequence of type scala.xml.NodeSeqwith all fruits and sub-nodes inside.
How can I limit this sequence to only contain fruit elements with a โbananaโ inside. those. I want the result to be:
<fruits>
<fruit>
<name>banana</name>
<taste>yellow</taste>
</fruit>
<fruit>
<name>banana</name>
<taste>green</taste>
</fruit>
<fruits>
source
share