Dear Users,
<note>
<to>ToText</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>
I am in need to get the string length of XML
tag using Xpath
. I am using string-lenth()
, but not able to render exact result.
Is there a way to get string-lenght(/to)
or string-lenght(/from)
?
As you know, the best way to find the length of a string is by using the strlen() function.
The length or size of a string means the total number of characters present in it. For Example: The string “Geeks For Geeks” has 15 characters (including spaces also).
Java String length method() The Java String class contains a length() method that returns the total number of characters a given String contains. This value includes all blanks, spaces, and other special characters. Every character in the String is counted.
The length() method returns the length of a specified string. Note: The length of an empty string is 0.
Try to use below XPath
:
//from/string-length(text())
or
//to/string-length(text())
Mathias Muller is correct, this should work:
string-length(/note/to)
or string-length(/note/from)
please check your spelling of length as well.....
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With