xml - Xpath function to find out string length of an attribute -
i have xml message body below. need find out if string length of attribute 'senderid' greater 0. unable find this.
xml message
<?xml version="1.0"?> <audit xmlns="http://schemas.auditlog.xsd"> <messageid>1234</messageid> <senderdetails createddate="2017-jan-12" senderid="app1"/> </audit>
i using below xpath function string length of senderid
when(xpath("string-length(string(//node()[local-name()='senderdetails']/@[local-name()='senderid']/text()))>0))
but not working.
this xpath,
string-length(//*[local-name() = 'senderdetails']/@senderid)
will return 4 because attribute value of @senderid
app1
, has string length of 4. can test return value appending > 0
if wish return true positive numbers.
see how xpath deal xml namespaces? learn how declare , use namespace prefix in xpath, preferable defeating namespaces via local-name()
.
Comments
Post a Comment