[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Appending to an XML document

  • From: Ross Bleakney <rossb@w...>
  • To: "'xml-dev@i...'" <xml-dev@i...>
  • Date: Tue, 7 Dec 1999 15:08:31 -0800

appending to an xml file
My apologies if you have already read this in the XSL list. I (and
apparently several other people) have a need to append an element onto an
existing XML file. I would like to avoid reading in the whole document and
then writing it back out again. My original plan was to open the file, find
the end of it, back up a bit to find the last tag, write the new element and
then rewrite the closing tag. I am looking for a generic solution.

I know of no XML API that allows for modifying a document. They make it easy
to create new documents out of old ones, but they don't allow you to modify
an existing file. Doing so would mean the possibility of optimization that
would greatly reduce disk I/O. For example, if you had XML like this:

<Events>
   <Event>...<Event>
   <Event>...<Event>
</Events>

It would be really nice to write code like this:

	ModifyXML modXML = new ModifyXML("MyDoc.XML");	
	Element event = modXML.createElement("Event");
	event.appendChild(modXML.createTextNode("A big event happened"));
	modXML.appendChild("Events", event);
	modXML.update();

An implementor of this interface could take advantage of the fact that
<Events> is the main tag and perform the same sort of work I suggested
(backing up from the end and then writing). The routines for this interface
would be very limited since this would only be used when you want to modify
a document and you know that using SAX (or DOM) is inefficient. Thus there
would be no reason to have an "insertBefore". The API could be limited to
appending and deleting. 

Is there something like this already?

Thanks,
Ross

xml-dev: A list for W3C XML Developers. To post, mailto:xml-dev@i...
Archived as: http://www.lists.ic.ac.uk/hypermail/xml-dev/ and on CD-ROM/ISBN 981-02-3594-1
To unsubscribe, mailto:majordomo@i... the following message;
unsubscribe xml-dev
To subscribe to the digests, mailto:majordomo@i... the following message;
subscribe xml-dev-digest
List coordinator, Henry Rzepa (mailto:rzepa@i...)



PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.