开发者

Do you know any valuable alternative to XML_Serializer which is up-to-date?

开发者 https://www.devze.com 2023-03-12 07:51 出处:网络
I\'m in need to serialize object into XML and XML_Serializer should do that, however, the version is still in beta, not much active (no activity since 2开发者_开发百科010-10) and still depends on PHP4

I'm in need to serialize object into XML and XML_Serializer should do that, however, the version is still in beta, not much active (no activity since 2开发者_开发百科010-10) and still depends on PHP4.

I'd rather avoid to write such tool myself, so may you know an alternative?


http://querypath.org/ is actively developed. https://github.com/technosophos/querypath

It is much more advanced (broader focus...), but seems to be a really useful tool.


A library that offers an XML representation of serialized objects is Serialized.

Writing an XML Serializer for PHP objects (and other values) is as easy as:

/**
 * XML object serializer
 */
function XML_Serialize($object)
{
    require_once('/path/to/Serialized.php');
    $parser = new Serialized\Parser(serialize($object));
    return $parser->getDump('XML');
}

Unlike XML_Serializer PEAR Package this is one-way so far. However you have specifically written "I'm in need to serialize object into XML", so I'm not entirely sure if you really need to unserialize from XML as well. This can be done by parsing the XML into the array notation of serialized which should be quite trivial.

After that's done, the only thing left is to call the Serialized dumper on that array structure and unserialize the output.

0

精彩评论

暂无评论...
验证码 换一张
取 消