All pastes #48043 Raw Edit

Anonymous

public text v1 · immutable
#48043 ·published 2006-04-04 00:35 UTC
rendered paste body
<?php
//http://oviedo.itrebal.com/xmlv2.php
error_reporting(2047);
ini_set('display_errors', true);

$xml = simplexml_load_file('../cfiles/index.inc.php');
printp_r($xml);
foreach($xml as $key => $value){
  printp_r($key);
  printp_r($value);
}

printp_r(loop($xml));
function loop($xml){
  $out = array();
  foreach($xml as $key => $value){
    if(is_object($value)){
      printp_r($value, $key.'_o');
      $out[$key] = loop($value);
    }elseif(is_array($value)){
      printp_r($value, $key.'_a');
      $out[$key] = loop($value);
    }else{
      printp_r($value, $key.'_e');
      $out[$key] = $value;
    }
  }
  return $out;
}

function printp_r($what, $header = false){
  echo '<pre>';
  if($header !== false)
    echo '--------'.$header.'---------'."\n";
  print_r($what);
  echo '</pre>';
}
?>

contents: 

<page>
  <elem refid="title" attr="title" />
  <elem refid="content" attr="content" />
  <template>standard</template>
  <title>OVIEDO: Online Virtual Inventory for the English Department of Oviedo</title>
  <content>OVIEDO:Online Virtual Inventory for the English Department of Oviedo</content>
</page>