• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

how to append data

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for your reply.
I'll make you more clear what I want.
If this is my xml file
<books>
<person>
<first>Tom</first>
<last>Cruise</last>
<age>45</age>
</person>
</books>

Now when I append some data, I should have my previous data in it. Like
<books>
<person>
<first>Tom</first>
<last>Cruise</last>
<age>45</age>
</person>
<person>
<first>Tom</first>
<last>Hanks</last>
<age>48</age>
</person>
</books>

This is how I want. But my data gets overwritten with previous data and I show up as
<books>
<person>
<first>Tom</first>
<last>Hanks</last>
<age>48</age>
</person>
</books>
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If your original file has a complete XML document in it, there is no simple way to just append more text because what results is an illegal XML document.
You might treat this as a purely text problem by reading the original file to locate and remove the closing root element </books> and adding more text.

Or you might read the original into memory as a DOM and append data using the DOM methods.

Bill
 
reply
    Bookmark Topic Watch Topic
  • New Topic