<?xml version="1.0" encoding="UTF-8"?>
<Matriculas>
<Matricula IdPortagem=" 1,0">
<LicensePlate>50-PX-53</LicensePlate>
<EntryDate>2016-11-11 19:02:24</EntryDate>
<ExitDate>2016-11-11 19:13:39</ExitDate>
<EntryPoint>Angeiras S-N</EntryPoint>
<ExitPoint>Povoa S-N</ExitPoint>
<Value>2,0</Value>
<IsPayed>N</IsPayed>
<PaymentDate />
</Matricula>
<Matricula IdPortagem=" 2,0">
<LicensePlate>50-PX-53</LicensePlate>
<EntryDate>2016-11-11 17:27:05</EntryDate>
<ExitDate>2016-11-11 17:27:05</ExitDate>
<EntryPoint>ER1-18</EntryPoint>
<ExitPoint>ER1-18</ExitPoint>
<Value>0,45</Value>
<IsPayed>N</IsPayed>
<PaymentDate />
</Matricula>
<Matricula IdPortagem=" 3,0">
<LicensePlate>50-PX-53</LicensePlate>
<EntryDate>2016-11-11 12:48:36</EntryDate>
<ExitDate>2016-11-11 12:48:36</ExitDate>
<EntryPoint>Miramar</EntryPoint>
<ExitPoint>Miramar</ExitPoint>
<Value>0,45</Value>
<IsPayed>N</IsPayed>
<PaymentDate />
</Matricula>
<Matricula IdPortagem=" 4,0">
<LicensePlate>50-PX-53</LicensePlate>
<EntryDate>2016-11-10 21:34:31</EntryDate>
<ExitDate>2016-11-10 21:34:31</ExitDate>
<EntryPoint>Povoa S-N</EntryPoint>
<ExitPoint>Povoa S-N</ExitPoint>
<Value>1,1</Value>
<IsPayed>N</IsPayed>
<PaymentDate />
</Matricula>
</Matriculas>所以我这里有一个小的XML,我试图得到一个大于3的EntryPoint。
我使用的是这个表达式
/Matriculas//Matricula[Value>3,0]/EntryPoint似乎我做错了什么..。有谁能帮帮我吗?
发布于 2016-11-22 14:06:51
我正在尝试获取
的EntryPoint,值大于3。
这里的问题是,您正在尝试比较两个数字-但是XPath/XSLT要求数字使用.点作为小数分隔符。使用小数逗号的值不被视为数字。
相反,尝试:
/Matriculas//Matricula[translate(Value, ',', '.') > 3]/EntryPoint上面的方法适用于XPath/XSLT 1.0。要使其面向未来,请使用:
/Matriculas//Matricula[number(translate(Value, ',', '.')) > 3]/EntryPoint当然,如果您的输入示例实际包含一个Value大于3的Matricula,则会有所帮助。
https://stackoverflow.com/questions/40732194
复制相似问题