I have an XML that I need to search for some node combinations. In specific, I need to find posts where node2 is empty and node4 is empty too. So suppose the following XML:
<data>
<post>
<node1>111</node1>
<node2>222</node1>
<node3>333</node1>
<node4>444</node1>
<node5>555</node1>
</post>
<post>
<node1>111</node1>
<node2/>
<node3>333</node1>
<node4>444</node1>
<node5>555</node1>
</post>
<post>
<node1>111</node1>
<node2>222</node1>
<node3>333</node1>
<node4/>
<node5>555</node1>
</post>
<post>
<node1>111</node1>
<node2/>
<node3>333</node1>
<node4/>
<node5>555</node1>
</post>
<post>
<node1>111</node1>
<node2>222</node1>
<node3>333</node1>
<node4>444</node1>
<node5>555</node1>
</post>
</data>
So I tried this pattern <node2/>[\n\s\S]+?<node4/>
, but it catches also the cases where node2 is empty up until it finds an empty node4, even if it spans across many posts. I need to do some complex lookahead/lookbehind to confine it into the boundaries of a single post. The correct result would be to get only the 4th post.
Can someone help me with this?
For the genius that closed the topic: This has nothing to do with XML parsing... I need to find those cases in an XML to investigate the returned data in order to determine how to deal with them...