#### use strict; use warnings; use XML::LibXML; my $d = XML::LibXML::Document->new; $d->setDocumentElement( my $r = $d->createElement( q{root} ) ); $r->setNamespace( q{http://foo}, q{foo}, 0 ); my $p = $r->addChild( $d->createElement( q{parent} ) ); my $c = $p->addChild( $d->createElement( q{foo:child} ) ); printf qq{child->prefix=%s, child->localname=%s\n}, $c->prefix, $c->localname; #### $c->setAttribute( q{foo:abc}, q{123} ); my $an = $c->getAttributeNode( q{foo:abc} ); printf qq{an->prefix=%s, an->name=%s\n}, $an->prefix, $an->name;