Read Write Edit XML files

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
wickidgrafx
Forum Newbie
Posts: 2
Joined: Tue Aug 25, 2009 2:37 pm

Read Write Edit XML files

Post by wickidgrafx »

I need a very simple script to load an XML file into an html file and be able to edit that datat and then save it back to that file. I have seen similar scripts but they just append data not edit and replace.

Here is a small example of one of the XML files I need to edit.

Code: Select all

<fresh_images>
<image thmb="fresh_images/1_thmb.jpg" big="fresh_images/1.jpg"/>
<image thmb="fresh_images/2_thmb.jpg" big="fresh_images/2.jpg"/>
<image thmb="fresh_images/3_thmb.jpg" big="fresh_images/3.jpg"/>
<image thmb="fresh_images/4_thmb.jpg" big="fresh_images/4.jpg"/>
<image thmb="fresh_images/5_thmb.jpg" big="fresh_images/5.jpg"/>
<image thmb="fresh_images/6_thmb.jpg" big="fresh_images/6.jpg"/>
<image thmb="fresh_images/7_thmb.jpg" big="fresh_images/7.jpg"/>
<image thmb="fresh_images/8_thmb.jpg" big="fresh_images/8.jpg"/>
<image thmb="fresh_images/9_thmb.jpg" big="fresh_images/9.jpg"/>
<image thmb="fresh_images/10_thmb.jpg" big="fresh_images/10.jpg"/>
<image thmb="fresh_images/11_thmb.jpg" big="fresh_images/11.jpg"/>
<image thmb="fresh_images/12_thmb.jpg" big="fresh_images/12.jpg"/>
</fresh_images>
the three XML files I am using are set up the same way. I appreciate and examples or suggestions.
Mark Baker
Forum Regular
Posts: 710
Joined: Thu Oct 30, 2008 6:24 pm

Re: Read Write Edit XML files

Post by Mark Baker »

PHP's simpleXML functions?
wickidgrafx
Forum Newbie
Posts: 2
Joined: Tue Aug 25, 2009 2:37 pm

Re: Read Write Edit XML files

Post by wickidgrafx »

I looked into SimpleXML but couldn't grasp how to edit information like I stated about. Like I said everything that I found just appended data to the file.
Mark Baker
Forum Regular
Posts: 710
Joined: Thu Oct 30, 2008 6:24 pm

Re: Read Write Edit XML files

Post by Mark Baker »

$xml->movie[0]->characters->character[0]->name = 'Jim Phelps';
Post Reply