in reply to Re: How might one determine empty XML payload?
in thread How might one determine empty XML payload?

I'm a bit confused here. $input_xml should change to the value you set in $xml when my database request gets to the end of the table. So I substituted $xml for $input_xml and I am getting the following error. Not sure how to use the library correctly yet.

XML::LibXML->load: specify location, string, or IO at ./ServiceNowCMDB_ALL_CI_DumpXML.pl line 99.

  • Comment on Re^2: How might one determine empty XML payload?

Replies are listed 'Best First'.
Re^3: How might one determine empty XML payload?
by haukex (Archbishop) on Jun 02, 2016 at 14:30 UTC

    Hi vlturner,

    XML::LibXML->load: specify location, string, or IO at ...

    What does the code look like that is causing this error? Maybe $input_xml is undef (Data::Dumper), or perhaps you wrote XML::LibXML->load_xml($input_xml) by accident?

    Regards,
    -- Hauke D

      Here is the code.

      my $input_xml; open my $fh, '>>:encoding(utf8)', $outputfile or die "Cannot open: $ou +tputfile: $!"; do { my $dom = XML::LibXML->load_xml(string=>$input_xml); my $isEmpty = !$dom->documentElement->hasChildNodes; print "isEmpty: ", ($isEmpty?"yes":"no"), "\n"; say $fh $input_xml; $offset = $offset + $record_limit +50000 ; print "Offset=$offset\n"; } while ($input_xml = Get_CMDB_CI()); close($fh) || warn "close failed: $!";

        Make use of your flag to exit the loop.

        my $input_xml; open my $fh, '>>:encoding(utf8)', $outputfile or die "Cannot open: $ou +tputfile: $!"; do { my $dom = XML::LibXML->load_xml(string=>$input_xml); my $isEmpty = !$dom->documentElement->hasChildNodes; print "isEmpty: ", ($isEmpty?"yes":"no"), "\n"; last if $isEmpty; say $fh $input_xml; $offset = $offset + $record_limit +50000 ; print "Offset=$offset\n"; } while ($input_xml = Get_CMDB_CI()); close($fh) || warn "close failed: $!";
        But God demonstrates His own love toward us, in that while we were yet sinners, Christ died for us. Romans 5:8 (NASB)