Read the id attribute of a tag in SVG file with getElementById using PHP

I have an SVG file named rectangle.svg (UPDATED)

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" 
  "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg width="300" height="130" xmlns="http://www.w3.org/2000/svg">
  <rect id="myid" width="200" height="100" x="10" y="10" rx="20" ry="20" fill="blue" />
  <rect id="myid2" width="200" height="100" x="10" y="10" rx="20" ry="20" fill="blue" />
</svg>

I try to read rect id with the readid.php (UPDATED):

<?php
    $dom = new DOMDocument("1.0", "utf-8");
    $dom->load('rectangle.svg');
    if ($dom->validate()) {
        echo "This document is valid!n";
    }
    $div = $dom->getElementById('myid');
    echo 'Result: '.$div->getAttribute('id');
?>

Output of php readid.php is:

This document is valid!
Result:

Why does not read the id attribute?

I would like to read the attributes and values of

<rect id="myid" width="200" height="100" x="10" y="10" rx="20" ry="20" fill="blue" />