title: php loop xml data with xsd schema - how do get the data
body: <p>i try to geht the data from a xml file and i have troubles to get data,
  for example, how can i get the caaml:locRef value or the caaml:beginPosition value?</p>
  
  <p>here is the code so far:</p>
  
  <pre><code>/* a big thank you to helderdarocha */
  /* – he already helped me yesterday with a part of this code */ 
  
  $doc = new DOMDocument();
      $doc-&gt;load('xml/test.xml');
  
      $xpath = new DOMXpath($doc);
      $xpath-&gt;registerNamespace("caaml", "http://caaml.org/Schemas/V5.0/Profiles/BulletinEAWS");
  
      if ($doc-&gt;schemaValidate('http://caaml.org/Schemas/V5.0/Profiles/BulletinEAWS/CAAMLv5_BulletinEAWS.xsd')) {
  
          foreach ($xpath-&gt;query('//caaml:DangerRating') as $key) {
              echo $key-&gt;nodeValue;
              print_r($key);
          }
  
      } 
  </code></pre>
  
  <p>and here ist the print_r from $key</p>
  
  <pre><code>DOMElement Object ( [tagName] =&gt; caaml:DangerRating [schemaTypeInfo] =&gt; [nodeName] =&gt; caaml:DangerRating [nodeValue] =&gt; 2014-03-03+01:00 2 [nodeType] =&gt; 1 [parentNode] =&gt; (object value omitted) [childNodes] =&gt; (object value omitted) [firstChild] =&gt; (object value omitted) [lastChild] =&gt; (object value omitted) [previousSibling] =&gt; (object value omitted) [nextSibling] =&gt; (object value omitted) [attributes] =&gt; (object value omitted) [ownerDocument] =&gt; (object value omitted) [namespaceURI] =&gt; http://caaml.org/Schemas/V5.0/Profiles/BulletinEAWS [prefix] =&gt; caaml [localName] =&gt; DangerRating [baseURI] =&gt; /Applications/MAMP/htdocs/lola/xml/test.xml [textContent] =&gt; 2014-03-03+01:00 2 ) 2014-03-04+01:00 2 
  </code></pre>
  
  <p>and here a part of the xml </p>
  
  <pre><code> &lt;caaml:DangerRating&gt;
        &lt;caaml:locRef xlink:href="AT7R1"/&gt;
        &lt;caaml:validTime&gt;
          &lt;caaml:TimePeriod&gt;
            &lt;caaml:beginPosition&gt;2014-03-06T00:00:00+01:00&lt;/caaml:beginPosition&gt;
            &lt;caaml:endPosition&gt;2014-03-06T11:59:59+01:00&lt;/caaml:endPosition&gt;
          &lt;/caaml:TimePeriod&gt;
        &lt;/caaml:validTime&gt;
        &lt;caaml:validElevation&gt;
          &lt;caaml:ElevationRange uom="m"&gt;
            &lt;caaml:beginPosition&gt;2200&lt;/caaml:beginPosition&gt;
          &lt;/caaml:ElevationRange&gt;
        &lt;/caaml:validElevation&gt;
        &lt;caaml:mainValue&gt;2&lt;/caaml:mainValue&gt;
      &lt;/caaml:DangerRating&gt;
      &lt;caaml:DangerRating&gt;
        &lt;caaml:locRef xlink:href="AT7R1"/&gt;
        &lt;caaml:validTime&gt;
          &lt;caaml:TimePeriod&gt;
  </code></pre>
  
  <p>thanks!</p>