I am currently parsing an XML document and storing the XML data in a String[]. This is what I do:
db = dbf.newDocumentBuilder();
Document dom = db.parse(in);
Element docElem = dom.getDocumentElement();
NodeList valuesList= docElem.getElementsByTagName("values");
Element value = (Element) valuesList.item(0);
//Split on every white space
String[] myValues = value.getFirstChild().getNodeValue().split("\\s+");
System.out.println(myValues.length);
//Output: 5400
for(String val : myValues){
System.out.println("Value: " + val);
//This prints out random amount of lines in the console, see figure.
}
The output from the loop varies. See the picture below.
The result could be 4145 the first execution and 4198 the second time.
Shouldn't this output be 5400 lines since the String[] holds 5400 items? Why is it not?
Thankful for any kind of explanation.
Marcus