Print XML Node e Attribute in PHP

May 6, 2018 10:17 am Published by

La seguente procedura, stampa il primo livello dei nodi di un oggetto XML in PHP.

echo "Node " . $xml->getName() . "<br />";
foreach($xml->attributes() as $attr_name => $attr_value) 
{
   echo "Attribute " . $attr_name.'="'.$attr_value.'"<br>';
}

foreach($xml->children() as $child)
{
  echo "Node " . $child->getName() . ": " . $child . "<br />";
  foreach($child->attributes() as $attr_name => $attr_value) 
  {
		echo "Attribute " . $attr_name.'="'.$attr_value.'"<br>';
  }
}

Categorised in: ,

This post was written by admin

Comments are closed here.