in reply to Replace xml first id

The XPath expression ./id will try to find an element <id> below the current node.

What you are looking for is an attribute named id of the current node. The XPath syntax for attributes is @id, but I guess you're better off using the ->getAttribute() method:

my $id = $object11->getAttribute('id');