I have an xml file that looks like this:
...
<e1>
<e2>
<e3>content1.1</e3>
<e3>content1.2</e3>
...
<e3>content1.n</e3>
</e2>
<e2>
<e3>content2.1</e3>
<e3>content2.2</e3>
...
<e3>content2.n</e3>
</e2>
...
</e1>
...
I need a regex that given the xml string (a bunch of e1 elements), would match the all e2 elements that have a child e3 element with content contentx. In other words, the regex would match all e2 elements (could have different e1 parents) where each of these elements has at least one e3 child who’s contents equal contentx.
Don’t use a regex to parse XML. Just don’t do it. This is precisely the sort of thing that XPath was made to do. I would offer an XPath expression, but I’m not completely sure what you are trying to match.