472,791 Members | 1,531 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,791 software developers and data experts.

appending a new element to an existing xml file

Hi,
Is there anyway I can append a new element to an existing xml without
first loading the existing file into a variable, adding the new
element into the variable and saving it by overwriting the existing
file name?

Thanks
Ofuuzo
Mar 5 '08 #1
1 3724
of*****@yahoo.no wrote:
: On 5 Mar, 14:23, ofuu...@yahoo.no wrote:
: Hi,
: Is there anyway I can append a new element to an existing xml without
: first loading the existing file into a variable, adding the new
: element into the variable and saving it by overwriting the existing
: file name?

If your concern is the physical act of efficiently adding data to an
existing file (such as what happens to log files) then I think the two
ways to do this would be

-1- Dont add the closing tag until you're finished adding data to the
file. Simply append each xml-snippet as needed. If you need to manipulate
the file before you're done then create a copy that has a closing tag.
-2- Each time you prepend the next set of data you need to truncate the
file slightly to remove the last line (containing the closing tag). If
the closing tag is a constant then you know the length to truncate,
otherwise you need to examine the last N bytes to find the location of the
last tag, and truncate enough bytes to remove it before appending the new
data.
$0.10
Mar 5 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Fnark! | last post by:
I am creating a shopping cart using PHP Version 4.1.2. I am creating and registering a cart object in a session. The cart object contains an array of arrays called $order whose elements are a...
0
by: Red Ogden | last post by:
I would really appreciate some advice on the best way to do this. The problem is this: I want to create a web form where the user specifies an existing XML file name and a value for attribute on...
4
by: Jesper Stocholm | last post by:
I have a database class that maintains data about customers i my system. The basic XML for this looks like: <Chunk> <Vendor> <Database/> </Vendor> </Chunk> When a user is to be registrered...
2
by: Cat | last post by:
How do you go about appending data from a dataset to an existing xml file? I know you can use WriteXML but this writes over any data already existing in the specified file.. Cat
1
by: onemonk | last post by:
hi guys... I hav this problem, I am planning to write html form values to xml file and... the problem is... When I am entering data... its recording only the latest entry.. by overwriting the...
3
by: Jim | last post by:
Could anyone please point me towards some code that allows me to add to an existing XML file using the output of an HTML form. I want to add a form on my website so users can input their email...
1
by: Frank | last post by:
Hi, Let's say I have a file named myFile.xml Within that file I have blocks of data which I'd like to add at different times during the day. e.g. <LogEntry>
1
by: ofuuzo1 | last post by:
Hei, I am having issue using DOM to appending a new xml file (new.xml) to another existing xml file (old.xml) without deleting the existing items in old.xml. I would like to have the new...
0
by: ghafarifar | last post by:
How I appending a new node to am existing xml file? help?
0
by: Rina0 | last post by:
Cybersecurity engineering is a specialized field that focuses on the design, development, and implementation of systems, processes, and technologies that protect against cyber threats and...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
linyimin
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
0
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
0
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
0
by: lllomh | last post by:
How does React native implement an English player?
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.