#!/usr/bin/perl use strict; use warnings; use feature 'say'; use Mojo::DOM; my $xml = '
item_a item_b
'; my $dom = Mojo::DOM->new->xml(1)->parse( $xml ); # say current attribute value say 'Current value: ' . $dom->at('idset:first-of-type')->attr('id'); # change it to something $dom->at('idset:first-of-type')->attr(id => 'derp'); # dump the whole DOM say $dom->content;