XmlReader Plugin Behavior

What, exactly, does the following code return, if there are no child nodes?

nodes = XmlNode.getChildNodes( nodeObject )

The reason I am asking…

I wrote a method to traverse an xml data object using recursion (the method calls itself). The first thing the method checks is whether XmlNode[ 0 ].getChildNodes() returns a null value, and, if so, ends (returns) that instance of the method. The problem is that I get duplicate nodes. Empirically, I discovered that I must test the no-child node this way:

if ( arrayChildNodes[ 0 ].getName != '#text' )

to detect when getChildNodes() returns no child nodes.

The method works with the ‘fix’, but I am curious why it does not detect a null value.

Does anyone have any experience with this Plugin that could explain what is happening?

Thanks!

there is no such thing as XmlNode.getChildNodes( nodeObject )

but only

nodeObject.getChildNodes()

that one will return an empty array if there are no childs.

My apologies, my mistake in posting…the parent node is passed to the recursive method, the child nodes are extracted into an array, then the test follows:

This code works:

function getChildNode()
{
    var parentNode = arguments[ 0 ]
                             
    var arrayChildNodes = parentNode.getChildNodes()

   if ( arrayChildNodes[ 0 ].getName() == '#text' ) return

This code below does not work:

function getChildNode()
{
    var parentNode = arguments[ 0 ]
                             
    var arrayChildNodes = parentNode.getChildNodes()

   if ( arrayChildNodes == null ) return

The follwoing codes does not work, either.

function getChildNode()
{
    var parentNode = arguments[ 0 ]
                             
    var arrayChildNodes = parentNode.getChildNodes()

   if ( arrayChildNodes[ 0 ] == null ) return

If there are no child nodes, shouldn’t a null be returned?

f ( arrayChildNodes.length == 0 ) return

the childnodes are never null, only empty