首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Xpath误导表达式

Xpath误导表达式
EN

Stack Overflow用户
提问于 2016-11-22 09:06:53
回答 1查看 54关注 0票数 1
代码语言:javascript
复制
<?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。

我使用的是这个表达式

代码语言:javascript
复制
/Matriculas//Matricula[Value>3,0]/EntryPoint

似乎我做错了什么..。有谁能帮帮我吗?

EN

回答 1

Stack Overflow用户

发布于 2016-11-22 14:06:51

我正在尝试获取

的EntryPoint,值大于3。

这里的问题是,您正在尝试比较两个数字-但是XPath/XSLT要求数字使用.点作为小数分隔符。使用小数逗号的值不被视为数字。

相反,尝试:

代码语言:javascript
复制
/Matriculas//Matricula[translate(Value, ',', '.') > 3]/EntryPoint

上面的方法适用于XPath/XSLT 1.0。要使其面向未来,请使用:

代码语言:javascript
复制
/Matriculas//Matricula[number(translate(Value, ',', '.')) > 3]/EntryPoint

当然,如果您的输入示例实际包含一个Value大于3的Matricula,则会有所帮助。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/40732194

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档