smitha Posted November 21, 2007 Share Posted November 21, 2007 Hi, I am new to PHP programming. Can you tell me how can I serialize an object to an XML? I found some help online but it is pretty simple with only elements. What I want is to serialize an object into XML with some attributes and some elements. Could you please guide me? Thanks, Smitha Quote Link to comment Share on other sites More sharing options...
BenInBlack Posted November 21, 2007 Share Posted November 21, 2007 you should be fine using the built in PHP serialize functions and use CDATA in the xml $doc->createCDATASection($elementvalue) Quote Link to comment Share on other sites More sharing options...
smitha Posted November 21, 2007 Author Share Posted November 21, 2007 Thanks for the quick response. Can you refer to me an example? As I said I'm a new bee to PHP. Thanks, Smitha Quote Link to comment Share on other sites More sharing options...
smitha Posted November 21, 2007 Author Share Posted November 21, 2007 Hi, I think I understood what you are pointing to. But I want to write my class in such a way that when I serialize using (PEAR) it would generate required elements as attributes just like what we do in .NET (with an attribute to the property). Can I do that? Thanks, Smitha Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.