Re: appending to stored form input in xml file.... ????
| From: | Tomator | Date: | Tue, 18 Jun 2002 07:14:15 +0000 |
| Subject: | Re: appending to stored form input in xml file.... ???? | ||
| References: | 1 | Groups: | php.windows |
| Request: | Send a blank email to php-windows+get-14258@lists.php.net to get a copy of this message | ||
> im trying to store input from my form into ctnt.xml
> file thru
> ctnt.php
>
> the problem is ....
> how do i append to this file ie
> i want the input of each form subbmission to get
> stored in this same ctnt.xml
> without overwriting ....
>
> i now i sholud use $fp=fopen("c:\\name.xml", "a+");
> i get an error ven i try to open n.xml in internet
> explorer
> & here is the error i get :
>
> "XML document must have a top level element. Error
> processing resource file:///C:/n.xml'. "
It is rather clear. As HTML may have syntax errors and be correctly
displayed, an XML document can't. Any XML compilant processor will refuse to
process XML with errors.
An XML MUST have TOP LEVEL ELEMENT. HTML should have it also (<HTML> &
</HTML> pair). This means that you can NOT simply append some content do XML
file, becouse it would add some text AFTER ending tag of top element. I
haven't read your code, becouse I think your problem is with understanding
XML where everything MUST by correct.
To get correct results try to remove last line of XML document (with top
element's closing tag), append file and, finally, place closing tag. Or
store your data in database (such as textfile) and generate your XML
dynamically with PHP as others do.