Hi Monks!
I am parsing some XML but sometimes the XML doc coming in is not well formated, I am looking to trap the erros and after submit to myself an email. The problem I am having is this:
Software error:
Can't call method "appendChild" on an undefined value at
And here is the code I am using. Is there any other way to trap the erros?
my $xp = XML::XPath->new(filename => $open_this);
#####Test
my ($parser,$list_item,$file_list,$root_node);
eval {
$parser = XML::XPath::XMLParser->new( filename => $xp-> $open_
+this);
$root_node = $parser->parse;
$xp->find('/*', $root_node);
};
if ($@) {
# if we get an error, include the details in the output.
$list_item->appendChild(XML::XPath::Node::Text->new("ERROR par
+sing file '$open_this': ". $@) );
$file_list->appendChild($list_item);
next FILE;
}
Thanks!!!
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.