![]() |
Writing to XML file
Hi All, ^^
I was originally going to use .txt files, then thought it'd be way better to use .xml files. So, now I have to write to them. My issue is, how to read between the "lines". Right now I have: PHP Code:
Code:
<?xml version="1.0" standalone="yes"?>Code:
<?xml version="1.0" standalone="yes"?>Would that be the best way? Thanks |
Welp, Icanhavethattookaboutasecond. I am still not exactally sure how to get stuff from between the lines...
PHP Code:
|
SimpleXML can actually create XML documents. However, it's not that great in my opinion - with its lack of support for CDATA blocks and no
removeNode function, it leaves a lot to be desired. I prefer DOM Document which also allows the creation of XML documents. Unfortunately, we don't have any articles really on this topic - not in any depth anyway, but here's a good old Google search that yields several good results by the looks of it.If you have any questions when reading those articles - just ask! |
i can think of 2 posts that you may find useful although they both kinda require some XML background knowledge:
http://www.talkphp.com/xml-xslt-xpat...-part-one.html TalkPHP - Creating RSS documents with the DOM API yea the php dom functions are really the best and indeed the easiest way to create XML docs in my opinion. this should hopefully get you started: PHP Code:
<?xml version="1.0" standalone="yes"?> <posts> <post> <title>Some people like meat.</title> <category>Meat</category> <pubDate>2008-January-15</pubDate> </post> </posts> |
Thanks for the responces. I found an article and have followed it, however, it's overwriting my data, not appending to it.
Here's my form post code: PHP Code:
|
You need to load from file, then append your elements. If you look at the code you create a new document and then save it. Of course it overwrites the old during this process. ;-)
|
yes, load an xmlfile into the dom as robertk says, it does most of the hard work for you :)
PHP Code:
|
Hello all,
So I have loaded the XML file into the dom, however, each time it still overwrites it with this code: PHP Code:
PHP Code:
Here is my whole dom xml creator... I think it is almost there... just the overwrite problem. I don't understand that. PHP Code:
|
PHP Code:
you also need the new keyword: PHP Code:
PHP Code:
|
| All times are GMT. The time now is 10:07 PM. |
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0