note 76409 deleted from function.xml-parse-into-struct by cmb
| From: | cmb@php.net | Date: | Sun, 21 Oct 2018 09:33:24 +0000 |
| Subject: | note 76409 deleted from function.xml-parse-into-struct by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-209477@lists.php.net to get a copy of this message | ||
Note Submitter: php dot net at crazedsanity dot com
----
If you're interested in something that creates arrays in PHP, handles attributes well, and is
easily transferrable back into XML, you may want to take a look at the cs-phpxml project at
SourceForge.net (http://sf.net/projects/cs-phpxml). It's not necessarily documented very well,
but it will do something like this:
<?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(
* type => 'open',
* attributes => array(
* xmlns => 'stuff'
* )
* INDEXONE => 'hello',
* MY_SINGLE_INDEX = array(
* type => 'complete',
*
* )
* )
* );
*/
?>
It's presently under development, but I'm using it in several production environments.
The XMLCreator is kinda clunky (builds XML within PHP code). NOTE: it has a dependency on
"cs-arraytopath", also available at sourceforge via http://sf.net/projects/cs-arraytopath . The setup
is a bit irritating, and it's fragile when handling quoting & formatting the data, but I
think it's worth the hassle for most projects.