Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Check whether XML tag exist in Java

I am parsing an XML javax.xml, but i want to know whether a tag exist on a child node For example

<tag>
 <child>
  <special_tag>Special</special_tag>
  <normal_tag>Normal</normal_tag>
 </child>
 <child>
  <normal_tag>Normal</normal_tag>
 </child>
</tag>

I am trying to know which Child has Special tag and which doesnt

like image 983
Necronet Avatar asked Apr 28 '26 23:04

Necronet


1 Answers

Using xPath:

//child[special_tag]
like image 53
Boris Pavlović Avatar answered May 01 '26 13:05

Boris Pavlović