Hi all, I was wondering if its possible to add elements onto an existing XML file and how that would happen. To be more elaborate, I have a xml file like following structure:
<ASX version="3.0">
<ENTRY><REF href="http://www.mydomain.com/File1.wmv" /></ENTRY>
<ENTRY><REF href="http://www.mydomain.com/File2.wmv" /></ENTRY>
<ENTRY><REF href="http://www.mydomain.com/File3.wmv" /></ENTRY>
</ASX>
Now, I have a situation where I am required to insert another entry like "<ENTRY><REF href="http://www.mydomain.com/xxx.wmv" /></ENTRY>" in the above file structure. Obviously every time a new xml file write (for just a single new entry) will not be a good solution to my problem.
Anyone have any idea??? Thanks in advance..
Modifying XML file
Moderator: General Moderators
xml file edit
Sorry for creating confusion.
Actually, all the solutions and suggestions I got to include a new entry in the existing xml file is to write the file again (I mean not just appending the new entry) with all the previous entries + the new entry. But that not seemed to be a feasible solution...because, say I already have 99 entries in that xml file. Now for the new 100-th entry I have to write the same file with all 99 + 1 new entry.
I think, now I've made it clear. Sorry my english is not good enough. Thank you.
Actually, all the solutions and suggestions I got to include a new entry in the existing xml file is to write the file again (I mean not just appending the new entry) with all the previous entries + the new entry. But that not seemed to be a feasible solution...because, say I already have 99 entries in that xml file. Now for the new 100-th entry I have to write the same file with all 99 + 1 new entry.
I think, now I've made it clear. Sorry my english is not good enough. Thank you.
Re: xml file edit
And that's bad because .... ?surath wrote:because, say I already have 99 entries in that xml file. Now for the new 100-th entry I have to write the same file with all 99 + 1 new entry.
Re: xml file edit
Isn't it a bad approach??? For just one new entry, I have to read the entire file for old entries, storing them, appending the new entry with those existing entries and then write the file again.volka wrote:And that's bad because .... ?surath wrote:because, say I already have 99 entries in that xml file. Now for the new 100-th entry I have to write the same file with all 99 + 1 new entry.
All I have to say is, Is there any way to edit the xml file and append the new entry into it?
- Gente
- Forum Contributor
- Posts: 252
- Joined: Wed Jun 13, 2007 9:43 am
- Location: Ukraine, Kharkov
- Contact:
What for do you use your XML?
For example if it's created for outside access you can do following.
Write a little php script, which will output header, footer and include the middle part, stored in independent file.
This middle part you can append with new records ('a' or 'a+' flag of fopen() function).
Also don't forget to set correct Content-Type
For example if it's created for outside access you can do following.
Write a little php script, which will output header, footer and include the middle part, stored in independent file.
This middle part you can append with new records ('a' or 'a+' flag of fopen() function).
Also don't forget to set correct Content-Type