I am using the php XML_Serializer library from Pear. http://pear.php.net/manual/en/package.xml.xml-serializer.php
I would like to serialize something of the form
<a/>
<b/>
<a/>
where element order matters.
Does anyone know the format of the input for this? Thanks.
I don’t think this is possible with XMLSerializer. The closest I think you can get is setting a default element name of
awith thedefaultTagNameoption and using a numeric key for ‘a’ values.XML_Serializer is really designed as a simple serializer for PHP data structures (with its companion XML_Unserializer), much like the
serialize()andunserialize()functions. Since PHP doesn’t natively support a structure like this, XMLSerializer doesn’t either.XML_Serializer is also very old.
Have you considered using
SimpleXML,XMLWriteror evenDOMDocumentfor this? All three are built in to PHP, so you won’t even need an external PEAR library.