2024-01-20T02:53+01:00 ()

tried some XML::Twig

A piece of code that updates /feed/updated from latest /feed/entry/(updated|published)

use warnings;
use XML::Twig;
my $twig=XML::Twig->new();
my $filename= "$ENV{HOME}/mibsite/log.xml";
my $upd= $twig->root->first_child('updated');
my $max= $upd->text;
foreach my $entry ($twig->root->children('entry')) {
    foreach my $type ('published', 'updated') {
	my $cur= $entry->first_child($type);
	if ($type eq 'updated' && ! defined $cur) {
	if ($max lt $cur->text) {
	    $max= $cur->text; }
$twig->print_to_file($filename, pretty_print=>'cvs', empty_tags=>'html');

Meant to just get started with that, but ended up not liking XML::Twig all that much after all, once it came to wanting to use XPath and having to grasp the whole concept of XML::Twig::Elt, despite it all being relatively lite and relatively tidy.

https://www.perlmonks.org/?node_id=1045290 "XML::Twig parsefile_inplace misunderstanding" Yeah: when "print" is said (https://metacpan.org/pod/XML::Twig) to be not for use during parsing, and yet the whole mode of processing that inplace works for is supposed to happen in handlers kinda during (?) parsing i think, and the parse_inplace doesn't mention that fact when saying how print gets reassigned... Not likey.