-4

I want to split a sub xml from mail xml with the help of the node name. Can some one help?

sample.xml

<div>
<a>A
<b>B
<c>C</c>
</b>
<d>D</d>
</a>
</div>

I want to split the sub xml that contains B using Scala.

Ilya
  • 4,583
  • 4
  • 26
  • 51
Barath
  • 107
  • 2
  • 14
  • 1
    Scala has a library for xml manipulation https://github.com/scala/scala-xml Also, what have you tried already? Could you provide us some runnable code that we can copy-paste into IDE and tune in from there? – sebszyller Aug 25 '16 at 12:37
  • I have not tried anything still,I am new to scala,can you pls tell me how this library can help me? – Barath Aug 25 '16 at 12:42

1 Answers1

2

This will get you the required xml subtree. Refer scala xml parsing

val x = <div><a>A<b>B<c>C</c></b><d>D</d></a></div>
val b = x \ "a" \ "b" 
Samar
  • 2,091
  • 1
  • 15
  • 18
  • Thks,I am getting this in my ide after executing b: scala.xml.NodeSeq = NodeSeq(),how to get the value of b? – Barath Aug 25 '16 at 12:54