Xpath substring-before gets only one element

<row transactionDateTime="2012-06-04 02:42:44" transactionID="2519826732" quantity="5000" typeName="Caldari Navy Mjolnir Rocket" typeID="27321" price="988.72" clientID="92026367" clientName="N Clover" stationID="60003760" stationName="Jita IV - Moon 4 - Caldari Navy Assembly Plant" transactionType="buy" transactionFor="personal" journalTransactionID="5956192510"/>

Hello,

Above is an example of an XML file from which I am trying to extract data. The piece of data I want to extract is:

transactionDateTime="2012-06-04"

Now - I have no problem getting the next Xpath request;

substring-before(//row[@transactionfor='personal']/attribute::transactiondatetime, ' ')

This gives me exactly what I want - "2012-06-04", but it only gets one item! If I drop the substring - before it gets all the elements, but turns on the time.

Any help would be great!

+3
source share
2 answers
substring-before(//row[@transactionfor='personal']/attribute::transactiondatetime, ' ') 

XPath 1.0, node , (), node node -set. string() node string($nodeset) string($node-set[1]).

XPath 2.0 .

, XPath , , 1.

node (, , , XPath).

XPath 2.0 .

, XPath 2.0:

//row[@transactionfor='personal']
           /attribute::transactiondatetime
                           /substring-before(., ' ') 
+2

, substring-before() , transactionDateTime .

:

//row[@transactionFor='personal']/substring-before(@transactionDateTime,' ')
+1

Source: https://habr.com/ru/post/1648955/


All Articles