Re: appending to XML file before closing tag

From: Date: Wed, 26 Jun 2002 00:42:22 +0000
Subject: Re: appending to XML file before closing tag
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-103866@lists.php.net to get a copy of this message
I was actually thinking about this the other day - every now and again I find my self yearning for SGML, where you could have just declared the wrapping element "end tag omissable", and then you would never have to worry about it - basically the end of the file would imply the existence of the end tag (sigh .... ) One solution could be to use an entity..... the log file is just included in the wrapping XML file. Best illustrated by an example: File log.xml: ============ <!DOCTYPE loglist [ <!ELEMENT loglist (logitem+) > <!ELEMENT logitem (#PCDATA) > <!ENTITY logitems SYSTEM "logitems.ent" > ]> <loglist> &logitems; </loglist> File logitems.ent: ================== <logitem>LOg message number 1</logitem> <logitem>Log message number 2</logitem> <logitem>Log message number 3</logitem> Not sure if I have got the syntax exactly right but it would be something like this. But if it works, then all you have to do is append to the end of logitems.ent. At 23:31 25/06/2002, William S. wrote:
This works pretty well to append content to an XML file. However, I need to keep the closing tag where it belongs: at the end of the file. This only appends to the end and doesn't work. I use ... $myecho = "Hello World"; $file_name = "file.xml"; $file_pointer = fopen($file_name, "a"); fwrite($file_pointer, $myecho); fclose($file_pointer); I know I need to introduce: fread() and fseek(). but not sure how to put it all together. Anyone? -- Bill Amsterdam, NL -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
------------------------- Brian White Step Two Designs Pty Ltd Knowledge Management Consultancy, SGML & XML Phone: +612-93197901 Web: http://www.steptwo.com.au/ Email: bwhite@steptwo.com.au Content Management Requirements Toolkit 112 CMS requirements, ready to cut-and-paste

« previous php.general (#103866) next »