Page 1 of 1

Evaluate XPath command

Posted: Wed Sep 16, 2015 10:24 am
by Frank
I've got an XML like so (thank you W3schools :) ):

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>

<bookstore>

<book>
  <title lang="en">Harry Potter</title>
  <price>29.99</price>
</book>

<book>
  <title lang="en">Learning XML</title>
  <price>39.95</price>
</book>

</bookstore>


And I've got code like this:

Code: Select all

~InstallAware Clipboard Data~
~Evaluate XPath Query~
~{A280858C-6078-45D2-A0D1-348959A6AAC8}~
~"C:\hello.xml"~
~/~
~BLUT~
~0~


(which translates to)

Code: Select all

Evaluate Query / on XML "C:\hello.xml", get result into variable BLUT as type Full XML String


Running this I would expect the variable BLUT to contain the whole XML, but it returns empty.
I wanted to get a value deeper than root, but since that didn't work either (bookstore/book/price).
So I tried to get the whole thing, but even that doesn't work.

What am I doing wrong? :oops:

Re: Evaluate XPath command

Posted: Wed Sep 16, 2015 12:09 pm
by FrancescoT
Dear Frank,

you cannot use the "Evaluate XPath Query" command to get the Whole xml file content, If you need so, you may use the "Read from Text File" command instead.

For what concerns the "Evaluate XPath Query" command syntax, please have a look at the attached sample and to the following links.
http://www.installaware.com/forum/viewtopic.php?f=2&t=10051&hilit=+xml#p37774
http://www.installaware.com/forum/viewtopic.php?f=4&t=9456

Regards

Re: Evaluate XPath command

Posted: Thu Sep 17, 2015 7:16 am
by Frank
After some experiments I got it working.

It had to do with several (nasty :roll: ) oversights on my side.
First off I concatenated a filename to a filepath, leaving me with a folder like:
c:\program files (x86)\My Company\My Product\Configuration.xml\Configuration.xml which doesn't exist.

Next, the XPath query is case-sensitive!! That'll throw you off guard. I (now) know it's in the XPath specs, but mentioning this in the help would be appreciated!

Third, using the wrong Result Type: I needed Node Text, but requested Node Value. That'll never match ofcourse.

Anyway, it's working.
Thanks for the input (once again).

Re: Evaluate XPath command

Posted: Thu Sep 17, 2015 12:06 pm
by FrancescoT
:D