title: XML Validation error: 'Can not find declaration of element "example".'
body: <p>I am creating an XML file from scratch using PHP's SimpleXML Object. But I am getting this error when validating the document: 'Can not find declaration of element "example".'</p>
  
  <p>Here is the code that is creating the XML document: </p>
  
  <pre><code>    $xml = new SimpleXMLElement('&lt;example&gt;&lt;/example&gt;');
      $xml-&gt;addChild('producers');
  
      foreach($producers as $i=&gt;$producer){
         $name = get_the_title($producer-&gt;ID);
         $owner = get_post_meta($producer-&gt;ID, '_producer_contact_name', true);
         $phone = get_post_meta($producer-&gt;ID, '_producer_phone', true);
         $fax = get_post_meta($producer-&gt;ID, '_producer_fax', true);
         $email = get_post_meta($producer-&gt;ID, '_producer_email', true);
         $website = get_post_meta($producer-&gt;ID, '_producer_website', true);
         $address = get_post_meta($producer-&gt;ID, '_producer_address', true);
  
         $xml-&gt;producers-&gt;addChild('producer');
         $xml-&gt;producers-&gt;producer[$i]-&gt;addChild('name', $name);
         $xml-&gt;producers-&gt;producer[$i]-&gt;addChild('owner', $owner);
         $xml-&gt;producers-&gt;producer[$i]-&gt;addChild('phone', $phone);
         $xml-&gt;producers-&gt;producer[$i]-&gt;addChild('fax', $fax);
         $xml-&gt;producers-&gt;producer[$i]-&gt;addChild('email', $email);
         $xml-&gt;producers-&gt;producer[$i]-&gt;addChild('website', $website);
         $xml-&gt;producers-&gt;producer[$i]-&gt;addChild('civic', $address[0]); 
         $xml-&gt;producers-&gt;producer[$i]-&gt;addChild('mailing', $address[1]); 
         $xml-&gt;producers-&gt;producer[$i]-&gt;addChild('town', $address[2]); 
         $xml-&gt;producers-&gt;producer[$i]-&gt;addChild('province', $address[3]); 
         $xml-&gt;producers-&gt;producer[$i]-&gt;addChild('postal', $address[4]);           
      }
  
      $open = fopen($file, 'w') or die ("File cannot be opened.");
      fwrite($open, $xml-&gt;asXML());
      fclose($open);
  </code></pre>
  
  <p>The XML that is produced is this: </p>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
     &lt;example&gt;
        &lt;producers&gt;
           &lt;producer&gt;
              &lt;name&gt;&lt;/name&gt;
              &lt;phone&gt;&lt;/phone&gt;
              &lt;fax&gt;&lt;/fax&gt;
              &lt;email&gt;&lt;/email&gt;
              &lt;website&gt;&lt;/website&gt;
              &lt;civic&gt;&lt;/civic&gt;
              &lt;mailing&gt;&lt;/mailing&gt;
              &lt;town&gt;&lt;/town&gt;
              &lt;province&gt;&lt;/province&gt;
              &lt;postal&gt;&lt;/postal&gt;
           &lt;/producer&gt;
        &lt;/producers&gt;
     &lt;/example&gt;
  </code></pre>
  
  <p>Any help would be appreciated! Thanks</p>