I need to filter many XML files like this:
<header>
<type>1</type>
<time>today</time>
</header>
<message>
<Event...>
<Counter...>
...
</message>
I need to pick only all the message content whose header.type == 1. I'm reading from multiple files I need to select the message content with type == 1.
I've just little updated your XML-structure to be well-formed. Here are several XML files for testing:
And simple code looks like this:
Output:
As you can see message has been fetched only in case if header is of type 1.
Therefore you can delete
.text()and do what you need with message node after simple not-null check.