简体   繁体   中英

Order of Child Elements w/ php XML_Serializer

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 a with the defaultTagName option 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() and unserialize() 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 , XMLWriter or even DOMDocument for this? All three are built in to PHP, so you won't even need an external PEAR library.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM