note 78708 added to function.xml-parse-into-struct
| From: | php dot net at crazedsanity dot com | Date: | Wed, 24 Oct 2007 14:32:38 +0000 |
| Subject: | note 78708 added to function.xml-parse-into-struct | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-131687@lists.php.net to get a copy of this message | ||
There's an updated version of cs-phpxml (http://sf.net/projects/cs-phpxml, or https://cs-phpxml.svn.sourceforge.net/svnroot/cs-phpxml/releases
for the latest out of subversion) which easily converts an XML string into a PHP array. Using my
previous example:::
<?php
/**
*
* *********** EXAMPLE ***********
*
* Original file contents:
* <test xmlns="stuff">
* <indexOne>hello</indexOne>
* <my_single_index testAttribute="hello" />
* <multiple_items>
* <item>1</item>
* <item>2</item>
* </multiple_items>
* </test>
*
* Would return:::
*
* array(
* TEST => array(
* indexOne => hello,
* my_single_index => NULL,
* multiple_items => array(
* items => array(
* 0 => 1,
* 1 => 2
* )
* ),
* ),
* );
*/
?>
I've been using this in many production environments, and it's been very stable. The
syntax is pretty simple, too:::
<?php
require_once(dirname(__FILE__) ."/cs-phpxml/xmlParserClass.php");
$xmlParser = new xmlParser(file_get_contents("test.xml"));
$myArray = $xmlParser->get_tree(TRUE);
?>
----
Server IP: 208.69.120.35
Probable Submitter: 208.107.163.91
----
Manual Page -- http://www.php.net/manual/en/function.xml-parse-into-struct.php
Edit -- https://master.php.net/note/edit/78708
Del: integrated -- https://master.php.net/note/delete/78708/integrated
Del: useless -- https://master.php.net/note/delete/78708/useless
Del: bad code -- https://master.php.net/note/delete/78708/bad+code
Del: spam -- https://master.php.net/note/delete/78708/spam
Del: non-english -- https://master.php.net/note/delete/78708/non-english
Del: in docs -- https://master.php.net/note/delete/78708/in+docs
Del: other reasons-- https://master.php.net/note/delete/78708
Reject -- https://master.php.net/note/reject/78708
Search -- https://master.php.net/manage/user-notes.php