The length of the string returned from getContent()

Hi, When I try to see the length of the content of a certain child in XML data, I found out it is always 3 more than it should be. Is that normal? For example, in the xml userData:

<?xml version="1.0" encoding="UTF-8"?> <userData> <user>u2017121229</user> <user>u2017121230</user> <user>u2017121230</user> <user>u201712123055</user> </userData> when I use getContent to get "u2017121230", it actually gives me a String of the size 14, instead of 11



  • I get 11 from getContent()'s length() for "u2017121230":

    XML xml = loadXML("userData.xml");
    XML thirdUser = xml.getChildren("user")[2];
    println(thirdUser); // <user>u2017121230</user>
    String s = thirdUser.getContent();
    println(s, s.length()); // u2017121230 11


  • It turns out that if there is a child attached to the node, the content will contain several empty "tails".

    for example: u2017121229 u2017121230<name/> u2017121230 u201712123055

Sign In or Register to comment.