[26337] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 8512 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Oct 11 14:05:16 2005

Date: Tue, 11 Oct 2005 11:05:06 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Tue, 11 Oct 2005     Volume: 10 Number: 8512

Today's topics:
        getElementsByTagName, tag does not exist (hymie!)
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Tue, 11 Oct 2005 10:28:01 -0500
From: hymie_@_lactose.homelinux.net (hymie!)
Subject: getElementsByTagName, tag does not exist
Message-Id: <BZCdnX_8atGcR9beRVn-uA@comcast.com>

Greetings.  I'm just starting to dabble in XML, and I've run across a
problem.

I'm going through my XML document using this construct:

use XML::DOM;
my $parser = new XML::DOM::Parser
                        or bail ("Unable to create XML parser");
my $story = $parser->parse($data);
$out{"SOURCE"} = $story->getElementsByTagName("Source")->
                        item(0)-> getFirstChild->getData;
$out{"DATE"} = $story->getElementsByTagName("Publication_Date")->
                        item(0)-> getFirstChild->getData;
$out{"TEXT"} = $story->getElementsByTagName("Body_Text")->
                        item(0)-> getFirstChild->getData or die "$!";

Everything works fine, until I get to a $story where Body_Text doesn't
exist.  I've looked through all of the XML::DOM docs that I can find,
but I can't find either a way to test if Body_Text exists, or what happens
when Body_Text doesn't exist.  The script stops with no obvious
diagnostic output -- it appears that the "die" never happens.

Can somebody show me the light?

hymie!       http://www.smart.net/~hymowitz       hymie_@_lactose.homelinux.net
===============================================================================
I've got an answer.  I'm going to fly away.  What have I got to lose?
                                                     --Crosby, Stills, and Nash
===============================================================================


------------------------------

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>


Administrivia:

#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc.  For subscription or unsubscription requests, send
#the single line:
#
#	subscribe perl-users
#or:
#	unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.  

NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice. 

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.

#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V10 Issue 8512
***************************************


home help back first fref pref prev next nref lref last post