xml


Xpath mislead Expression


<?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>
So I have this small XML here and I'm trying to get the EntryPoint of the Matricula with a Value bigger than 3.
I'm using this expression
/Matriculas//Matricula[Value>3,0]/EntryPoint
And it seems I'm doing something wrong... can anyone help me please?
I'm trying to get the EntryPoint of the Matricula with a Value bigger
than 3.
The problem here is that you are trying to compare two numbers - but XPath/XSLT expects numbers to use . dot as the decimal separator. Values using decimal comma are not considered to be numbers.
Try instead:
/Matriculas//Matricula[translate(Value, ',', '.') > 3]/EntryPoint
The above will work with XPath/XSLT 1.0. To make it future-proof, use:
/Matriculas//Matricula[number(translate(Value, ',', '.')) > 3]/EntryPoint
Of course, it would help if your input example actually contained a Matricula with a Value larger than 3.

Related Links

JAXB unmarshalling inXml flag to full object
Get Unicode value from range in Excel with VBA
How to define multiple criteria for joining data from multiple XML files using XQuery?
Replace '0' by 'nan' in an xml property using a regex in Dreamweaver
XSLT 1.0, Nmap XML, display part of a large attribute value, not sure best method to template
XML parsing in apex salesforce
Objective C: Using spritesheet from TexturePacker without GameEngine
Write a tr069 emulate client with perl?
R programming XML: accessing duplicate node
Cannot find the declaration of element 'xs:schema'
Webservice schema validation not working
How to define XSD element to have multiple children, all of which are simple and only have attributes?
App Engine - Java Cache Control wont work
XML list types required for WCF
What is the meaning of xs:mixed without elements?
Copy xml element with whole tree

Categories

HOME
algorithm
django
embedded
xml
eclipse
scikit-learn
adal
turing-machines
angular2-material
fftw
rom
hugo
python-multithreading
crystal-reports-2013
opengl-3
teechart
arangodb
android-securityexception
redis-sentinel
jsonpath
libc
favicon
code-generation
zerobrane
modbus-tcp
package.json
identity-management
connector
charles
inno-download-plugin
angular-routing
roslyn
imageresizer
mongoid6
dapper-extensions
jackson-modules
oculus
progress-bar
fractions
linked-data
intersystems-cache
eviews
postback
jmockit
r-grid
carriage-return
pdw-file-browser
getlasterror
fiware-cygnus
video-capture
sim-card
odroid
demo
attributeerror
wmp
preloader
lpsolve
bindingnavigator
http-request
photos
mesosphere
dynamic-linq
libgphoto2
magento-2.0.7
globalize
bluez
azure-cli
template-toolkit
cmp
py2neo
universal-analytics
shinobi
gets
meteor-packages
pacemaker
android-wake-lock
concept-insights
ascii-art
jdi
apache-commons-daemon
avahi
broadband
cryptographichashfunction
apache-spark-1.3
verold
jquery-slider
spring-remoting
code-duplication
ebay-lms
unit-of-work
inappsettingskit
scringo
wp7test
windows-98
cascadingdropdown
chart-director
robotlegs
intersect
curb
extreme-programming
infobright
convention
qglwidget
cac
commerceserver2007
timertask
dot-emacs
openfaces
opml
tabpanel
interop-domino
sifr3
contentpresenter
online-storage
blind

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App