note 98054 added to book.simplexml

[email protected]
Newsgroups php.notes
Message-ID <[email protected]>
Simple XML in an array of strings without objects:

<?php
   function xml2array($xml) {
      $arXML=array();
      $arXML['name']=trim($xml->getName());
      $arXML['value']=trim((string)$xml);
      $t=array();
      foreach($xml->attributes() as $name => $value) $t[$name]=trim($value);
      $arXML['attr']=$t;
      $t=array();
      foreach($xml->children() as $name => $xmlchild) $t[$name]=xml2array($xmlchild); 
      $arXML['children']=$t;
      return($arXML);
   }

   $xml = simplexml_load_file('file.xml');
   echo '<pre>';
   print_r(xml2array($xml));
   echo '</pre>';
?>
----
Server IP: 83.137.20.135
Probable Submitter: 83.161.221.132
----
Manual Page -- http://www.php.net/manual/en/book.simplexml.php
Edit        -- https://master.php.net/note/edit/98054
Del: integrated  -- https://master.php.net/note/delete/98054/integrated
Del: useless     -- https://master.php.net/note/delete/98054/useless
Del: bad code    -- https://master.php.net/note/delete/98054/bad+code
Del: spam        -- https://master.php.net/note/delete/98054/spam
Del: non-english -- https://master.php.net/note/delete/98054/non-english
Del: in docs     -- https://master.php.net/note/delete/98054/in+docs
Del: other reasons-- https://master.php.net/note/delete/98054
Reject      -- https://master.php.net/note/reject/98054
Search      -- https://master.php.net/manage/user-notes.php
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.