title: evaluating xml document element gives type issue: null is not an object
body: <p>Using the phpsqlajax.php script from the sql/google maps tutorial, it seems that I have managed to generate xml elements(markers) with values from mysql. Though nothing is being echoed to the page, the markers list is being populated via mysql according to the console log.<br>
  1. Does that necessarily mean the xml is being generated properly?</p>
  
  <p>I ask because the phpsqlajax_map_v3.php script gets one error report:
  evaluating xml document element gives type issue null is not an object.<br>
  2. That seems to be saying that the marker node is empty, and therefore not getting the values from mysql.</p>
  
  <p>the code:<br>
  \\\EDITED WORKING SCRIPT\\\<br>
  phpsqlajax.php <a href="https://developers.google.com/maps/articles/phpsqlajax_v3#populatetable%22google%20tutorial%20link%22" rel="nofollow">google tutorial link</a></p>
  
  <pre><code>&lt;?php
  
  // Start XML file, create parent node
  
      $dom = new DOMDocument("1.0");
  $node = $dom-&gt;createElement("markers");
  $parnode = $dom-&gt;appendChild($node); 
  ?&gt;
  &lt;?  
      // connect
      $host = "localhost";
      $username = 'root';
      $psswrd = 'root';
      $db = 'sql_maps';
      $dbc = mysqli_connect($host, $username, $psswrd, $db);
  
      if(!mysqli_connect_errno() ) {
          } else { 
          die("Database failed: " . 
          mysqli_connect_error() .
          " ( " . mysqli_connect_errno() . " )"
          );
  
      }
  ?&gt;
  &lt;?php
  // Using PHP's domxml Functions to Output XML
  // Select all the rows in the markers table
  
      // get data
      $query = "SELECT * FROM markers WHERE 1";
  
      // catch resource(collection of database rows)
      $result = mysqli_query($dbc, $query);
      // check
      if($result) {
  
      } else {
          die("connection failed");
      }
  
  
  
  header("Content-type:  application/xml"); 
  
  while ($row = mysqli_fetch_assoc($result)){  
    // ADD TO XML DOCUMENT NODE  
    $node = $dom-&gt;createElement("marker");  
    $newnode = $parnode-&gt;appendChild($node);   
    $newnode-&gt;setAttribute("name",$row['name']);
    $newnode-&gt;setAttribute("address", $row['address']);  
    $newnode-&gt;setAttribute("lat", $row['lat']);  
    $newnode-&gt;setAttribute("lng", $row['lng']);  
    $newnode-&gt;setAttribute("type", $row['type']);
  } 
  
  echo $dom-&gt;saveXML();
  
  ?&gt;
  </code></pre>
  
  <p>phpsqlajax_map_v3.php</p>
  
  <pre><code>&lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
    &lt;head&gt;
      &lt;meta http-equiv="content-type" content="text/html; charset=utf-8"/&gt;
      &lt;title&gt;Google Maps AJAX + mySQL/PHP Example&lt;/title&gt;
  
              &lt;script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"&gt;&lt;/script&gt;
      &lt;script type="text/javascript"
        src="https://maps.googleapis.com/maps/api/js?key=keyIntentionallyLeftOut&amp;sensor=false"&gt;
      &lt;/script&gt;
      &lt;script type="text/javascript"&gt;
      //&lt;![CDATA[
  
      var customIcons = {
        restaurant: {
          icon: 'http://labs.google.com/ridefinder/images/mm_20_blue.png',
          shadow: 'http://labs.google.com/ridefinder/images/mm_20_shadow.png'
        },
        bar: {
          icon: 'http://labs.google.com/ridefinder/images/mm_20_red.png',
          shadow: 'http://labs.google.com/ridefinder/images/mm_20_shadow.png'
        }
      };
      var map;
      function load() {
        var map = new google.maps.Map(document.getElementById("map"), {
          center: new google.maps.LatLng(47.6145, -122.3418),
          zoom: 13,
          mapTypeId: 'roadmap'
        });
        var infoWindow = new google.maps.InfoWindow;
  
        // Change this depending on the name of your PHP file
        downloadUrl("../geo_scripts/phpsqlajax_genxml2.php", function(data) {
          var xml = data.responseXML;
          var markers = xml.documentElement.getElementsByTagName("marker");
          for (var i = 0; i &lt; markers.length; i++) {
            var name = markers[i].getAttribute("name");
            var address = markers[i].getAttribute("address");
            var type = markers[i].getAttribute("type");
            var point = new google.maps.LatLng(
                parseFloat(markers[i].getAttribute("lat")),
                parseFloat(markers[i].getAttribute("lng")));
            var html = "&lt;b&gt;" + name + "&lt;/b&gt; &lt;br/&gt;" + address;
            var icon = customIcons[type] || {};
            var marker = new google.maps.Marker({
              map: map,
              position: point,
              icon: icon.icon,
              shadow: icon.shadow
            });
            bindInfoWindow(marker, map, infoWindow, html);
          }
        });
      }
      function bindInfoWindow(marker, map, infoWindow, html) {
        google.maps.event.addListener(marker, 'click', function() {
          infoWindow.setContent(html);
          infoWindow.open(map, marker);
        });
      }
  
      function downloadUrl(url, callback) {
        var request = window.ActiveXObject ?
            new ActiveXObject('Microsoft.XMLHTTP') :
            new XMLHttpRequest;
  
        request.onreadystatechange = function() {
          if (request.readyState == 4) {
            request.onreadystatechange = doNothing;
            callback(request, request.status);
          }
        };
  
        request.open('GET', url, true);
        request.send(null);
      }
  
      function doNothing() {}
  
      //]]&gt;
  
    &lt;/script&gt;
    &lt;/head&gt;
  
    &lt;body onload="load()"&gt;
      &lt;div id="map" style="width: 500px; height: 300px"&gt;&lt;/div&gt;
    &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>3. Since this is generating xml from a script, how would I point the browser to the xml to see if it is valid or working?</p>
  
  <p>I've searched similar questions on stackoverflow, however it seems those fixes do not apply here, i.e.- content-type: xml, various syntax errors from google code tutorial, code structure, and more.</p>