XML_Serializer
pear.php.net
Swiss-army knife for reading and writing XML files. Creates XML files from data structures and vice versa.
XML_Serializer serializes complex data structures like arrays or object as XML documents. This class helps you generating any XML document you require without the need for DOM. Furthermore this package can be used as a replacement to serialize() and unserialize() as it comes with a matching XML_Unserializer that is able to create PHP data structures (like arrays and objects) from XML documents, if type hints are available. If you use the XML_Unserializer on standard XML files, it will try to guess how it has to be unserialized. In most cases it does exactly what you expect it to do. Try reading a RSS file with XML_Unserializer and you have the whole RSS file in a structured array or even a collection of objects, similar to XML_RSS.

Since version 0.8.0 the package is able to treat XML documents similar to the simplexml extension of PHP 5.
Stephan Schmidt
schst
schst@php-tools.net no
Chuck Burgess
ashnazg
ashnazg@php.net yes
2010-10-26
08:08:30
0.20.2
0.20.0
beta
beta
BSD License
Bug #17994 Installed into wrong path
4.2.0
1.4.0b1
XML_Util
pear.php.net
1.1.1
XML_Parser
pear.php.net
1.2.6
PEAR
pear.php.net
xml
0.2
0.2
beta
beta
2003-08-03
BSD License
inital release
0.4
0.4
beta
beta
2003-08-12
BSD License
added Unserializer removed bug with object typehint removed bug with unnameditem w/o _originalKey attribute uses XML_Util to validate tagname serializer does not break on resources anymore added support for __sleep() and __wakeup()
0.5
0.5
beta
beta
2003-08-14
PHP License
Unserializer is now able to unserialize XML files w/o type hints by automatically transforming multiple occurences of the same tag to an indexed array This is now similar to ext/simpleXML in PHP5 that means it can be used to parse any XML file, try it with your favorite RSS feed
0.6
0.6
beta
beta
2003-08-21
PHP License
Unserializer is able to return the name of the root tag, added 'complexType' option to XML_Unserializer, added possibility to create nested objects from any XML file, tagname is used as classname if no other class is specified, added 'overrideOptions' option that can be used to restore the default options for a serialization, added 'keyAttribute' option to XML_Unserializer, added Todo list
0.8
0.8
beta
beta
2003-09-23
PHP License
XML_Serializer: * added option: scalarAsAttribute to create tags with attributes from an array or object, * added option: prependAttributes to enable a prepend string for attributes (ensure they are different from type hints), * added option: attributeIndent to allow multiline tags, if a tag has several attributes; this makes it easier to read (requested by Yavor Shahpasov), * now requires XML_Util 0.4.1 or newer, * added option: mode => simplexml, allows you to serialize indexed arrays like simpleXML of PHP5 does: tags use name of the parent structure and are in the same depth (this is still in alpha state, not thoroughly tested)

XML_Unserializer: * added option: parseAttributes which allows you to parse tags with attributes, * added option: attributesArray to specify the name of the array in which attributes should be stored, * added option: prependAttributes to specify a prepend string for the generated array keys, * added option: contentName to specify the key for the content of a tag that contains also attributes * added option: tagMap, to change the names of the tags while parsing

Both: * removed bug that occured when instantiating w/o options (reported by Alan Knowles), * added options: keyAttribute, typeAttribute and classAtribute to allow user to specify attribute names for typehints, * added resetOptions(), * added setOption(), * added option: overrideOptions that allows you to reset to defaults for one call of serialize or unserialize, * added some very small docs to defaultOptions arrays
0.8.1
0.8.1
beta
beta
2003-09-23
PHP License
Bugfix release

XML_Serializer: * removed bug when using mode => simplexml and indexed arrays contained only scalar values, * removed bug with missing _originalKey attribute when serializing objects

XML_Unserializer: * added check for set{$propName} method to use methods to set properties in Unserializer instead of direct access
0.9
0.9
beta
beta
2003-10-13
PHP License
XML_Serializer: + added support for doctype declaration (requested by Lapo 'Raist' Luchini), * changed tagName option to rootName option (tagName is still supported but deprecated), + added rootAttributes option (thanks to Lapo 'Raist' Luchini), + added rootName option for serializing objects

XML_Unserializer: * removed bug with unserializing aggregated objects
0.9.1
0.9.1
beta
beta
2003-10-26
PHP License
fixed bug #105
0.9.2
0.9.2
beta
beta
2004-04-23
PHP License
fixed invalid multiple call to XML_Parser constructor
0.10.0
0.10.0
beta
beta
2004-05-24
PHP License
- fixed bug #1478 (Array to string conversion) - fixed bug #170 (RDF examples produce incorrect code) - added new options to XML_Serializer: attributesArray and contentName to match XML_Unserializer
0.10.1
0.10.1
beta
beta
2004-07-12
PHP License
fixed bug #1846 (unserialization bug with empty arrays)
0.11.0
0.11.0
beta
beta
2004-08-24
PHP License
Serializer: - Request #2019 (use classname as tagname in indexed arrays) - replaced double quotes with single quotes - some CS fixes

Unserializer: - added new option 'forceEnum' - replaced double quotes with single quotes
0.11.1
0.11.1
beta
beta
2004-08-25
PHP License
Serializer: - fixed bug with default line endings
0.12.0
0.12.0
beta
beta
2004-11-03
PHP License
Serializer: - added new option tagMap (requested by Toby) Unserializer: - added encoding option (thanks to mc[at]glouglou[dot]net)
0.13.0
0.13.0
beta
beta
2004-11-06
PHP License
Serializer: - fixed bug #2688: in simplexml mode $array needs to be non-empty (thanks to demian[at]phpkitchen[dot]com and derek[at]hostbaby[dot]com) Unserializer: - implemented Request #2650: Multiple key attributes
0.13.1
0.13.1
beta
beta
2004-11-26
PHP License
Serializer: - fixed error handling (suppress error handling, when XML_Util returns an error) (patch by Lukas Smith) - replaced some left-over tabs with spaces
0.14.0
0.14.0
beta
beta
2004-12-22
PHP License
Serializer: - new option 'encodeFunction' to apply a PHP function to character data and attributes before serializing the data Unserializer: - Does no longer extend XML_Parser (allows to change encoding at runtime), this could break some scripts - new option 'targetEncoding' to specify the target encoding for character data - new option 'decodeFunction' to apply a PHP function on character data and attributes while unserializing the document - some tiny whitespace fixes Global: - new requires XML_Parser 1.2.2 and XML_Util 1.1.0
0.14.1
0.14.1
beta
beta
2004-12-27
PHP License
Bugfix release: - XML_Unserializer now again extends PEAR to use PEAR error management
0.15.0
0.15.0
beta
beta
2005-02-12
PHP License
XML_Serializer: - added option to return the result directly from serialize() XML_Unserializer: - added option to return the result directly from unserialize(), - added defaultClass option - added tagAsClass option (fixes Bug #3303) - fixed bug (tag name was not used as classname when tag was empty)
0.16.0
0.16.0
beta
beta
2005-06-05
PHP License
XML_Serializer: - introduced constants for all options (this helps avoiding typos in the option names) - deprecated option 'tagName' is no longer supported, use XML_SERIALIZER_OPTION_ROOT_NAME (or rootName) instead - implement Request #3762: added new ignoreNull option to ignore properties that are set to null when serializing objects or arrays - fixed bug with encoding function - use new header comment blocks XML_Unserializer: - fix bug #4075 (allow tagMap option to influence any kind of value)
0.17.0
0.17.0
beta
beta
2005-09-24
PHP License
XML_Serializer: - fixed bug #4575: use the return values of __sleep() when serializing objects - allow XML_SERIALIZER_OPTION_DEFAULT_TAG to be set as array to set different default tags based on the surrounding tag - allow XML_SERIALIZER_OPTION_SCALAR_AS_ATTRIBUTES to be set as array to selectively use scalar values as attributes - allow scalar values as first argument to serialize() - implemented request #3180: Add option to create cdata sections XML_Unserializer: - added constants for all options - fixed bug #5187: decode function should decode cdata instead of the element name - implemented request #3700: Treatment of whitespace can be influenced via an option
0.18.0
0.18.0
beta
beta
2005-10-02
PHP License
XML_Serializer: - Allow the use of '#default' whenever one wants to specify an option for any other key - fixed bug #4575 for real: XML_Serializer now expects __sleep() to return an array of property names XML_Unserializer: - Added new IGNORE_KEYS option to specify a list of tags which will not be unserialized using their names as keys - Added new GUESS_TYPE option to automatically convert the data to the best matching type - Allow COMPLEXTYPE to be an array to be able to unserialize to arrays or objects - Allow the use of '#default' whenever one wants to specify an option for any other tag
0.19.0a1
0.19.0a1
alpha
alpha
2008-08-24
BSD License
- switch to package.xml v2 - PEAR CS cleanup - Req #13856: License Change from PHP to BSD [ashnazg] - Bug #8048: Entities are not replaced in tags with attributes [schst] - Doc #12725: tuto link no more available
0.19.0
0.19.0
beta
beta
2008-09-15
BSD License
- switch to package.xml v2 - PEAR CS cleanup - Req #13856: License Change from PHP to BSD [ashnazg] - Bug #8048: Entities are not replaced in tags with attributes [schst] - Doc #12725: tuto link no more available
0.19.1
0.19.1
beta
beta
2008-10-21
BSD License
- Bug #14653: testNumberedObjects testcase fails [ashnazg] - Doc #8650 : Missing Information in the Manual [ashnazg] - Doc #13896: Bad info in the RSS feed tutorial [ashnazg]
0.19.2
0.19.2
beta
beta
2009-01-24
BSD License
- Bug #15602: attributes don't get escaped sometimes [lapo]
0.20.0
0.20.0
beta
beta
2010-09-04
BSD License
- Request #13564: bool(false) is converted to empty string
0.20.1
0.20.0
beta
beta
2010-10-25
BSD License
Automatically built QA release Bug #17848 XML_Serializer uses deprecated return new as reference - zigo
0.20.2
0.20.0
beta
beta
2010-10-26
BSD License
Bug #17994 Installed into wrong path