PHP/XML Content Management
- Started
- Last post
- 12 Responses
- londonBoy
Hey folks, i got bored today so decided to create a simple web-based content management system for clients to use for updating their sites.
I'm using php to write to an xml file which is then parsed through flash. So far so good. It works.
Q: Is there a way in PHP of checking for a string in the target xml document and then adding the new data directly after it.
ie: i have a header to define the xml doc (as required) then the opening node. [i then want the new data added here] before the exisiting content in the xml file.
Thanks in advance
- arlo0
Do a find/replace for that string (find it, replace it with itself AND the new data):
- londonBoy0
thanks arlo, i'll give it a try
- 187LockDown0
Use these Built in PHP Functions:
fopen()
fwrite()
rewind()
fseek()
ftell()
fclose()
flock()fputs() much like fwrite()
But it will append text to a file. instead of overwriting.
- 187LockDown0
Actually, don't take my word for that last piece of advice about the appending. Im not sure what the difference between the two functions really is. But your answer I believe will lie within those functions somewhere.
- 187LockDown0
Maybe I was right?
- 187LockDown0
WTF Dude,Did it work, where did you go?
- JazX0
Hey, it's funny, I was looking at this kinda' stuff. Isn't there something on it with the new data that Macromedia is giving out? Almost the same way via Flash PHP sends to SQL and then back through PHP and parsed with XML back into Flash module?
- londonBoy0
"WTF Dude,Did it work, where did you go?
187LockDown"
http://Doesn't_ anyone_ else_ on_ NT_ sleep?!?!
;)I'm still learning PHP so plz bear with me. Will give your suggestions a try.
A solution came to me in my dream last night [**doesn't the subconscious just rock**] so I'm going to see whether it works or not.
Does anyone else get that - in their subconscious, there is no limit to their logic and problem solving ability??? Solutions often come to me in my sleep.
"Wierdo" - i hear you cry.
- 187LockDown0
Well there is also a way to append to an XML file via flash & Actionscripting right? Can anyone tell us about that?
I just get frustrated sometimes because people like you. I gave you a perfect way of writing to a file and you tell me you will think about it. And you had a dream of doing some other way. WEll I bet your way fails if you have not taken any of the suggestions on writing to files using PHP. All this stuf is in tha manual. ANd sno we don't sleep ever.
- 187LockDown0
Saving XML to a file when used locally
- 256greys0
My subconscious is far better than me at javascript/actionscript.
It gives me all the answers.But then again, the bugs of the drivers of my ATI Radeon, are far better than me at finding good colors themes and crazy patterns.
- londonBoy0
187LockDown - thanks for all your help. I'm pleased to say I haven't had to touch the PHP file i had originally created. "If its not broken - why break it!" Right?
;)
In this particular content management example i was working on, it was based on a "latest news" type feed where clients would be able to add their own news via a web-based form.
Because i wanted it to display the most recent news first, i thought that the php had to write to xml placing the new data above all exisiting data. Make any sense!Well in my dream - it said: "why not, when parsed in flash, sort the data as normal but code it to display the data out in reverse order.
Its taken me all day but it now complete. whey-hey! :D