I am in need to get the value of <mathcolor>
element for the element <colorvalue>
has value 2. Please correct the Xpath expression given below:
Xpath Expression tried:
/colors/child::color/child::mathcolor[colorvalue='2']
Sample XML:
<?xml version="1.0"?>
<colors>
<color>
<mathcolor>#007dc5</mathcolor>
<textcolor>C=100 M=40 Y=0 K=0</textcolor>
<colorvalue>2</colorvalue>
</color>
<color>
<mathcolor>#ed1b34</mathcolor>
<textcolor>C=0 M=100 Y=85 K=0</textcolor>
<colorvalue>3</colorvalue>
</color>
</colors>
Almost, try that:
/colors/child::color[colorvalue='2']/child::mathcolor/text()
or simpler
/colors/color[colorvalue='2']/mathcolor/text()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With