There is such a dock:

<root> 1 <tr> a <tr> aa </tr> <fls> bb </fls> </tr> <fls> <tr> aaa </tr> <fls> bbb </fls> </fls> </root> 

And this code:

 element = doc.getDocumentElement(); NodeList nlist = element.getChildNodes(); System.out.println(nlist.getLength()); 

Why, then, do I get a length of 5 Whereas, how should I get 2, if doc.getDocumentElement(); gives me root which contains 2 children

  • one
    The root element contains a child node tr , a node fls , a text node \n\t1\n\t and two more text nodes \n\t . - Sergey Gornostaev
  • @SergeyGornostaev is it possible to bypass the extra nodes or how to form a dock. What would without the extra dance with a tambourine get the necessary information on the indices? - BogdanBida
  • It depends on what you need to do. Either you refer to specific nodes by name / use XPath or iterate over everything and work only with the necessary ones checking the type of the node. - ezhov_da

0