Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3210848
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T14:37:48+00:00 2026-05-17T14:37:48+00:00

Warning: I have no clue about how to work with XML. I have a

  • 0

Warning: I have no clue about how to work with XML.

I have a simple application whose only purpose is to persist ten properties about an object (a log, if you will). I wrote it rapidly and it writes the properties by appending them to a plain text file. Problem solved.

Now, I read that for simple applications like this one XML would be a good alternative. I don’t plan to change my script (being so simple, it works very well), but that left me thinking.

Say you want to create a log using XML.

How do you write an entry to it?

Do you read the whole XML file, append the entry, and rewrite the whole thing again? What I don’t understand is how to “append” to an XML file, considering that you cannot “append” to the middle of a plain text file without reading it, parsing it, and writing it again.

Please orient me.

Cheers.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T14:37:48+00:00Added an answer on May 17, 2026 at 2:37 pm

    XML isn’t really a good fit for anything you need to incrementally append to. A well-formed XML document has a single root element that encompasses (pretty much) the entire document. eg:

    <my-root>
      <a-child/>
      <another-child/>
      <yet-another-child/>
    </my-root>
    

    Appending one more child in this example would require that you insert the new child between <yet-another-child/> and the closing </my-root>. While it is possible to do this without having to rewrite the entire file by seeking to the end of <yet-another-child/> and writing the new tail, actually finding that position is complicated enough that sticking with something that supports true appends, like a flat text file, is probably the wiser option.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.