Changing LibXML to Twig.

This commit is contained in:
sergiotarxz 2023-05-02 18:19:32 +02:00
parent 423e813490
commit 50abdc0ac4
2 changed files with 4 additions and 7 deletions

View File

@ -18,7 +18,7 @@ my $build = Module::Build->new(
'DateTime::Format::ISO8601.pm' => 0,
'DateTime::Format::Mail.pm' => 0,
'SVG' => 0,
'XML::LibXML::PrettyPrint' => 0,
'XML::Twig' => 0,
},
);
$build->create_build_script;

View File

@ -10,8 +10,7 @@ use BurguillosInfo::Posts;
use DateTime::Format::ISO8601;
use XML::LibXML;
use XML::LibXML::PrettyPrint;
use XML::Twig;
use Mojo::Base 'Mojolicious::Controller', '-signatures';
@ -27,10 +26,8 @@ sub sitemap ($self) {
$self->_append_category_dom( $dom, $category_key, $categories );
}
my $xml_string = "$dom";
my $document = XML::LibXML->load_xml(string => $xml_string);
my $pretty_print = XML::LibXML::PrettyPrint->new(indent_string => (" " x 4));
$pretty_print->pretty_print($document);
$xml_string = $document->toString();
my $document = XML::Twig->new(pretty_print=> 'indented');
$xml_string = $document->parse($xml_string)->sprint;
$self->render(text => $xml_string, format => 'xml');
}