title: Trouble Extracting CDATA from Multi Level XML Result (API)
body: <p>Hi i have an issue extracting DATA from XML Output. The XML is as follows...</p>
  <pre><code>&lt;Question type=&quot;5&quot; text=&quot;What state was your SSN issued in?&quot;&gt;
  &lt;Answer correct=&quot;false&quot;&gt;Maryland&lt;/Answer&gt;
  &lt;Answer correct=&quot;false&quot;&gt;Alaska&lt;/Answer&gt;
  &lt;Answer correct=&quot;false&quot;&gt;Ohio&lt;/Answer&gt;
  &lt;Answer correct=&quot;false&quot;&gt;Indiana&lt;/Answer&gt;
  &lt;Answer correct=&quot;false&quot;&gt;Missouri&lt;/Answer&gt;
  &lt;Answer correct=&quot;false&quot;&gt;Washington&lt;/Answer&gt;
  &lt;Answer correct=&quot;false&quot;&gt;Arkansas&lt;/Answer&gt;
  &lt;Answer correct=&quot;false&quot;&gt;Illinois&lt;/Answer&gt;
  &lt;Answer correct=&quot;true&quot;&gt;Kentucky&lt;/Answer&gt;
  &lt;Answer correct=&quot;false&quot;&gt;None of the above&lt;/Answer&gt;
  &lt;/Question&gt;
  </code></pre>
  <p>My challenge is that when i use this code</p>
  <pre><code>$ch = curl_init($serviceUrl);
  curl_setopt($ch, CURLOPT_POST, 1);
  curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: text/xml'));
  curl_setopt($ch, CURLOPT_POSTFIELDS, $requestXml);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  $response = curl_exec($ch);
  curl_close($ch);
  // Debug output of the response
  libxml_use_internal_errors(TRUE);
   
  $objXmlDocument = simplexml_load_string($response,null,LIBXML_NOCDATA);
   
  if ($objXmlDocument === FALSE) {
      echo &quot;There were errors parsing the XML file.\n&quot;;
      foreach(libxml_get_errors() as $error) {
          echo $error-&gt;message;
      }
      exit;
  }
   
  $objJsonDocument = json_encode($objXmlDocument);
  $arrOutput = json_decode($objJsonDocument,true);
  </code></pre>
  <p>I can pull the data as an array and it all works fine with one exception. The correct attribute falls off the resulting array. and can not be called.</p>
  <p>It appears that array will take the question attributes type and text but since it is a sublevel of that it doesn't pickup on the correct attribute.</p>
  <p>My XML/Json knowledge is alright but this one has me stumped. Any ideas would be great.</p>
  <p>this is how i am parsing the data for the other parts of the project</p>
  <pre><code>$question_1 = $arrOutput['Response']['Questions']['Question']['0']['@attributes']['text'];
  $answer_choices_one = $arrOutput['Response']['Questions']['Question'][0]['Answer'];
  </code></pre>
  <p>My hope is when i use a foreach loop to build out the question choices to pickup on the correct attribute and store it in the value field of the input field i am using... I just can't seem to get the darn value.</p>
  <p>Thanks for your insights.</p>