From d74d1f186b2e2c6334a78b895b0ea811a16617a4 Mon Sep 17 00:00:00 2001 From: Emmanuel Seyman Date: Mon, 14 Jun 2021 21:12:07 +0200 Subject: [PATCH] fallback to toString() when toStringC14N(1) gives an empty string --- lib/HTML/TreeBuilder/LibXML/Node.pm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/HTML/TreeBuilder/LibXML/Node.pm b/lib/HTML/TreeBuilder/LibXML/Node.pm index f3b4e81..b710dda 100644 --- a/lib/HTML/TreeBuilder/LibXML/Node.pm +++ b/lib/HTML/TreeBuilder/LibXML/Node.pm @@ -74,7 +74,8 @@ sub as_HTML { { local $@; # protect existing $@ my $output = eval { $_[0]->{node}->toStringC14N(1) }; - return $@ ? $_[0]->{node}->toString : $output; + return $_[0]->{node}->toString if ($@ or $output eq ''); + return $output; } }