I'm trying to write a subroutine in Perl that will delete a given node in XML when provided with the text values of some of the children nodes.
Given XML like:
<Path>
<To>
<My>
<Node>
<ChildA>ValA</ChildA>
<ChildB>ValB</ChildB>
<ChildC>ValC</ChildC>
</Node>
</My>
</To>
</Path>
<!-- A lot of siblings follow... -->
The XPath expression I'm using is essentially:
/Path/To/My/Node[ChildA="ValA" and ChildB="ValB" and ChildC="ValC"]
When I'm trying to run my script, I'm getting an error like:
Error in XPath expression
/Path/To/My/Node[ChildA="ValA" and ChildB="ValB" and ChildC="ValC"] at
ChildA="ValA" and ChildB="ValB" and ChildC="ValC" at Twig.pm line 3353
I'm at a loss for this and am looking for suggestions. I've tried googling around, but I can't find working examples of trying to use predicates like this in XML::Twig
. I don't know if the problem is in my XPath syntax or how I'm using XML::Twig
.
For good measure, I've also tried:
/Path/To/My/Node[ChildA/text()="ValA" and ChildB/text()="ValB" and ChildC/text()="ValC"]
No luck with that either. What is the solution?