Using evaluateXPathAsString to get an attribute
Posted: 06 Nov 2015 21:31
I have this simple XML fragment and want to get the contents of the "full-path" attribute using the evaluateXPathAsString function.
Using an online xpath query tool I created two different (and apparently working) xpath strings and put them into a script action. "container_xml" naturally contains the xml from above:
Unfortunately, a following Debug condition shows both variables as empty. What did I do wrong?
Code: Select all
<?xml version="1.0"?>
<container version="1.0"
<rootfiles>
<rootfile full-path="volume.opf" media-type="application/oebps-package+xml" />
</rootfiles>
</container>
Code: Select all
rootFile1 = evaluateXPathAsString(container_xml, '/container/rootfiles/rootfile/@full-path');
rootFile2 = evaluateXPathAsString(container_xml, '//rootfile[@full-path]/@full-path');