Extracting child elements of an XML in Java



I have a requirement where I have to extract parts of XML child nodes and use it to generate reports.


Here is an example of the sample XML code :



<A>
<B>
<C>
<D>
</D>
<D>
</D>
</C>
</B>
<B>
<C>
<D>
</D>
</C>
</B>
<B>
<C>
</C>
</B>
</A>


I want to extract all the elements with B as XML tag name and use that to create reports. Could someone please explain how we can extract all the elements .


PS: These extracted elements should also have their child elements in it.


No comments:

Post a Comment