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 218373
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T18:44:40+00:00 2026-05-11T18:44:40+00:00

I want to save and load my xml data using XmlReader. But I don’t

  • 0

I want to save and load my xml data using XmlReader. But I don’t know how to use this class. Can you give me a sample code for start?

  • 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-11T18:44:41+00:00Added an answer on May 11, 2026 at 6:44 pm

    Personally I have switched away from XMLReader to System.XML.Linq.XDocument to manage my XML data files. This way I can easily pull data from xml into objects and manage them like any other object in my program. When I am done manipulating them I can just save the changes back out the the xml file at any time.

            //Load my xml document
            XDocument myData = XDocument.Load(PhysicalApplicationPath + "/Data.xml");
    
            //Create my new object
            HelpItem newitem = new HelpItem();
            newitem.Answer = answer;
            newitem.Question = question;
            newitem.Category = category;
    
            //Find the Parent Node and then add the new item to it.
            XElement helpItems = myData.Descendants("HelpItems").First();
            helpItems.Add(newitem.XmlHelpItem());
    
            //then save it back out to the file system
            myData.Save(PhysicalApplicationPath + "/Data.xml");
    

    If I want to use this data in an easily managed data set I can bind it to a list of my objects.

            List<HelpItem> helpitems = (from helpitem in myData.Descendants("HelpItem")
                      select new HelpItem
                      {
                           Category = helpitem.Element("Category").Value,
                           Question = helpitem.Element("Question").Value,
                           Answer = helpitem.Element("Answer").Value,
                      }).ToList<HelpItem>();
    

    Now it can be passed around and manipulated with any inherent functions of my object class.

    For convenience my class has a function to create itself as an xml node.

    public XElement XmlHelpItem()
        {
            XElement helpitem = new XElement("HelpItem");
            XElement category = new XElement("Category", Category);
            XElement question = new XElement("Question", Question);
            XElement answer = new XElement("Answer", Answer);
            helpitem.Add(category);
            helpitem.Add(question);
            helpitem.Add(answer);
            return helpitem;
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 112k
  • Answers 112k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer i dont think you are doing anything wrong. this seems… May 11, 2026 at 9:51 pm
  • Editorial Team
    Editorial Team added an answer The accepted answer for this question is actually not for… May 11, 2026 at 9:51 pm
  • Editorial Team
    Editorial Team added an answer I’d use this: RewriteEngine On # /admin/ rule RewriteCond %{REQUEST_FILENAME}… May 11, 2026 at 9:51 pm

Related Questions

I have an old system that uses XML for it's data storage. I'm going
All of the examples I can find online about this involve simply adding content
My question is best phrase as: Remove a child with a specific attribute, in
I'd like to take XML in the format below and load each code record
I have an XML that I want to load to objects, manipulate those objects

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.