PHP对象作为XML文档 [英] PHP Object as XML Document

查看:53
本文介绍了PHP对象作为XML文档的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

采用给定的PHP对象并将其序列化为XML的最佳方法是什么?我正在查看simple_xml,并用它来将XML解析为对象,但我不清楚它是如何工作的.

What is the best way to take a given PHP object and serialize it as XML? I am looking at simple_xml and I have used it to parse XML into objects, but it isn't clear to me how it works the other way around.

推荐答案

看看PEAR的 XML_Serializer 包.我用它取得了很好的效果.您可以向其提供数组,对象等,并将它们转换为XML.它还有很多选择,例如选择根节点的名称等.

take a look at PEAR's XML_Serializer package. I've used it with pretty good results. You can feed it arrays, objects etc and it will turn them into XML. It also has a bunch of options like picking the name of the root node etc.

应该做到这一点

这篇关于PHP对象作为XML文档的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆