W3C home > Mailing lists > Public > www-dom@w3.org > April to June 2001

Re: getData - Elements/Nodes will null values

From: osdx <osdx@etang.com>
Date: Mon, 16 Apr 2001 17:22:28 +0800 (CST)
Message-Id: <3ADAB9D4.04053@mail-smtp2>
To: www-dom@w3.org

At first you should judge if a node has childnodes (0)? If it has.you should get the length of childnodes (1) and get each childnode's nodetype (2).Here you can use a Switch to judge the childnode's nodetype.1 means the type of child is node,3 means the type of child is text.

0. ->hasChildNodes()

1. ->Getlength()

2. ->GetnodeType()

>I am having success with this command, with the exception of nodes that
>return NULL values. That is, the node actaully exists but there is no data
>for that node.
>eg:  <SellerPartNumber></SellerPartNumber>
>In addition I am using the following commands.
>	my $LineProdCode = $line->getElementsByTagName ("SellerPartNumber");
>     $Item  = $LineProdCode->[0]->getFirstChild->getData
>It seems to crash on the getData. 
> The module seems to be erroring out somewhere. Is there a way of checking
>for nodes that exist in an XML document that have null values. Is there any
>way I can trap any errors caused by the null node scenario. I could not find
>anything in the documentation.
>You advice would be greatly appreciated.
>Frank Fumic

Received on Monday, 16 April 2001 05:29:30 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 20 October 2015 10:46:08 UTC