2

I have the following example xml

<sub-flow name="TestSub_Flow" doc:id="20503297">
    <logger level="INFO" doc:name="Logger" doc:id="e92adc00" message="#[payload]"/>
    <annotations name="sampleName" />
</sub-flow>

I want to check if there is any annotation tag inside the 'sub-flow' tag using java. I have tried this using SAX but it seems to be a bit complicated. Which parser should I use to overcome this issue?

Basically I want to search this tag between the start and end of 'sub-flow'. Any solution is also welcome.

Vishnu
  • 176
  • 1
  • 2
  • 19
  • It may depend on the wider context of your XML, and what you want to do with the result of your check. But one approach is to use xPath (example code [here](https://stackoverflow.com/questions/62741613/i-want-to-extract-out-all-the-link-tags-from-this-xml-tree-using-java)). In your case, an xPath selector could be `"//sub-flow/annotations"`. Or just `"//sub-flow"` followed by a check of the result list's children. – andrewJames Jul 23 '20 at 18:12

0 Answers0