juan_in_nippon has asked for the wisdom of the Perl Monks concerning the following question:
I am trying to append user form info (ie. name, address) to an xml file between two xml open & close markers: <markers>... </markers>. Rather than appending with the standard Open >> which writes to EOF, I want to append newly submitted user form data before the closing </marker>.
Is there a quick and dirty way to alter my print routine below to always append a record just before the closing </markers>
I have tried to add a Print if statement but with not much luck! Any suggestions greatly appreciated!
Many thanks for any help in advance!
Printing routine follows below:
open (DATABASE, ">>$location_of_database") || &file_open_error("$location_of_database", "Append a Database" +, _FILE__, __LINE__); #Add new 'print if' code below to print new record before </markers +> print DATABASE "<marker $database_row />\n"; close (DATABASE); &release_file_lock ("$location_of_database.lock"); } # End of if (-w $location_of_database) # If the database file was not writable, the script # sends an error message back to the user. else { &cannot_find_database; exit; } } # End of if ($should_I_append_a_database eq "yes")
20070510 Janitored by Corion: Added formatting, code tags, as per Writeup Formatting Tips
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Appending a file between XML markers
by Joost (Canon) on May 09, 2007 at 11:07 UTC | |
|
Re: Appending a file between XML markers
by Jenda (Abbot) on May 09, 2007 at 13:32 UTC | |
|
Re: Appending a file between XML markers
by TOD (Friar) on May 09, 2007 at 11:00 UTC |