I have a xml like below. I want to get all direct child nodes under Node1. I am trying to use childNodes, however, it return Node21 and Node22 also. How can I just get those direct chirld nodes
<Node1>
<Node11>
<Node21>
</Node21>
<Node22>
</Node22>
<Node23>
</Node23>
</Node11>
<Node12>
</Node12>
<Node13>
</Node13>
</Node1>
UPDATE
Sorry for the confusion. I made a mistake, it seems it only get the direct child nodes. However, the item number is the childnodes still exceeds the real child nodes. I try to get the nodeName. I get a lot of “#text”
xml.ElementTree.Elementsupports the iterator protocol, so you can uselist(elem)as follows: