title: Amazon MWS Products API XML Parsing with PHP
body: <p>I am trying to parse the XML Part of the response with Simplexml without losing the "role" informations like "Komponist" or "Künstler" .</p>
  
  <pre><code>&lt;itemattributes xml:lang="de-DE" xmlns:ns2="http://mws.amazonservices.com/schema/Products/2011-10-01/default.xsd"&gt;
  &lt;ns2:binding&gt;Audio CD&lt;/ns2:binding&gt;
  &lt;ns2:brand&gt;MEYER,SABINE/VARIOUS&lt;/ns2:brand&gt;
  &lt;ns2:creator role="Künstler"&gt;Meyer,Sabine&lt;/ns2:creator&gt;
  &lt;ns2:creator role="Künstler"&gt;Various&lt;/ns2:creator&gt;
  &lt;ns2:creator role="Komponist"&gt;Mozart&lt;/ns2:creator&gt;
  &lt;ns2:creator role="Komponist"&gt;Stamitz&lt;/ns2:creator&gt;
  &lt;ns2:creator role="Komponist"&gt;Weber&lt;/ns2:creator&gt;
  &lt;ns2:creator role="Komponist"&gt;Krommer&lt;/ns2:creator&gt;
  &lt;/ns2:itemattributes&gt;
  </code></pre>
  
  <p>I have tried this:</p>
  
  <pre><code>    $nodeList = $attributeSets-&gt;getAny();
      foreach ($nodeList as $domNode){
          $domDocument =  new DOMDocument();
          $domDocument-&gt;preserveWhiteSpace = false;
          $domDocument-&gt;formatOutput = true;
          $xmlData = $domDocument-&gt;saveXML($domDocument-&gt;importNode($domNode,true));
  
      }
      //$xmlData  = str_replace("ns2:", "", $xmlData);
      $xmlData = new SimpleXMLElement($xmlData);
  </code></pre>
  
  <p>But if I do not replace the ns2 attributes, I can not parse the xml. And with uncommenting the line the role attributes are gone:</p>
  
  <pre><code>SimpleXMLElement Object
  (
      [Binding] =&gt; Audio CD
      [Brand] =&gt; MEYER,SABINE/VARIOUS
      [Creator] =&gt; Array
      (
          [0] =&gt; Meyer,Sabine
          [1] =&gt; Various
          [2] =&gt; Mozart
          [3] =&gt; Stamitz
          [4] =&gt; Weber
          [5] =&gt; Krommer
      )
  )
  </code></pre>
  
  <p>I would like to know, how I can hold these Attributes and maybe in the end how I could get the whole XML to an associative array.</p>