PHP - Editing XML documents with simplexml

Discuss how to write good code, break bad code, your current pet projects, or the best way to approach novel problems

PHP - Editing XML documents with simplexml

Post by ampakine on Sat Jul 02, 2011 5:54 pm
([msg=59322]see PHP - Editing XML documents with simplexml[/msg])

I've been playing around with the simplexml functions in PHP and I'm trying to get the addChild() function to add a new child element to an existing XML document and although I can echo the contents of this new element after I create it, the actual XML document doesn't get modified. Does the addChild() function not actually write to the XML file? In other words do I have to write the changes to the file myself with fwrite?
ampakine
Experienced User
Experienced User
 
Posts: 65
Joined: Tue May 31, 2011 5:21 pm
Blog: View Blog (0)


Re: PHP - Editing XML documents with simplexml

Post by fashizzlepop on Sat Jul 02, 2011 6:42 pm
([msg=59326]see Re: PHP - Editing XML documents with simplexml[/msg])

I would assume you read the file into memory and then alter it. Thus, any changes you make are not changed with the file and you would then need to export it.
The glass is neither half-full nor half-empty; it's merely twice as big as it needs to be.
User avatar
fashizzlepop
Developer
Developer
 
Posts: 2304
Joined: Sat May 24, 2008 1:20 pm
Blog: View Blog (0)



Return to Programming

Who is online

Users browsing this forum: No registered users and 0 guests

cron