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

  • SEARCH
  • Home
  • 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 9263965
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T13:42:35+00:00 2026-06-18T13:42:35+00:00

I have a Xml File below that I am trying to load in to

  • 0

I have a Xml File below that I am trying to load in to visual studio then append another entry for D100 to the file then write or append it 1000 times.

The code below saves the document but nothing gets appended.

<flp:Tab xmlns:flp="http://www.w3.org/2001/XMLSchema"   Title="Testing">
  <flp:Form Number="0" id="1005" />
  <flp:Rev Time="2013-01-21T15:08:00">
    <flp:Author Name="Brad" Aid="15" />
  </flp:Rev>
  <flp:Designs Id="D100">
    <flp:D100 Number="1">
      <flp:Code>A</flp:Code>
      <flp:Documented>true</flp:Documented>
      <flp:Note>In Process</flp:Note>
      <flp:Testers>
        <flp:Tester Name="David">
          <flp:Titles>
            <flp:Title Number="0" Name="Entry 1">
              <flp:Start>Begin</flp:Start>
              <flp:Finish>End</flp:Finish>
            </flp:Title>
          </flp:Titles>
        </flp:Tester>
      </flp:Testers>
      <flp:TestGivers>
        <flp:TestGiver Name="James" />
      </flp:TestGivers>
      <flp:IsRequired>true</flp:IsRequired>
      <flp:IsOptional>false</flp:IsOptional>
    </flp:D100>
  </flp:Designs>
</flp:Tab>

I am trying to append and write out the information 1000 times in the Xml File

Here is my C# code

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Xml;


namespace AppendXml
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
        }

        private void Button_Click_1(object sender, RoutedEventArgs e)
        {

            XmlDocument doc = new XmlDocument();
            doc.Load("C:\\Desktop\\Temp.xml");

            //XmlElement root = doc.CreateElement("Tab");

            XmlElement D100 = doc.CreateElement("D100");
            D100.SetAttribute("Number", "2");

            XmlElement Code = doc.CreateElement("Code");
            Code.InnerText = "B";

            XmlElement Documented = doc.CreateElement("Documented");
            Documented.InnerText = "false";

            XmlElement Note = doc.CreateElement("Note");
            Note.InnerText = "Complete";

            XmlElement Tester = doc.CreateElement("Tester");
            Tester.SetAttribute("Name", "John");

            XmlElement Title = doc.CreateElement("Title");
            Title.SetAttribute("Number", "0");
            Title.SetAttribute("Name", "Ronald");

            XmlElement Start = doc.CreateElement("Start");
            Start.InnerText = "Begin";

            XmlElement Finish = doc.CreateElement("Finish");
            Finish.InnerText = "End";

            XmlElement TestGiver = doc.CreateElement("TestGiver");
            TestGiver.SetAttribute("Name", "Jeremy");

            XmlElement IsRequired = doc.CreateElement("IsRequired");
            IsRequired.InnerText = "true";

            XmlElement IsOptional = doc.CreateElement("IsOptional");
            IsOptional.InnerText = "false";




            D100.AppendChild(IsOptional);
            D100.AppendChild(IsRequired);
            D100.AppendChild(TestGiver);
            D100.AppendChild(Finish);
            D100.AppendChild(Start);
            D100.AppendChild(Title);
            D100.AppendChild(Tester);
            D100.AppendChild(Note);
            D100.AppendChild(Documented);
            D100.AppendChild(Code);

            //root.AppendChild(D100);
            //doc.AppendChild(root);

            doc.Save("test13.xml");



        }
      }
    }

The document saves but noting appends. What am I leaving out?

  • 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-06-18T13:42:36+00:00Added an answer on June 18, 2026 at 1:42 pm

    You should append D100 to flp:Designs – now you are not appending it to anything, hence nothing gets added to the document:

    XmlNamespaceManager nsmgr = new XmlNamespaceManager(doc.NameTable);
    nsmgr.AddNamespace("flp", "http://www.w3.org/2001/XMLSchema");
    XmlNode designs = doc.SelectSingleNode("//flp:Designs", nsmgr);
    designs.AppendChild(D100);
    

    You are also creating D100 in the default namespace, probably you want to create it in the http://www.w3.org/2001/XMLSchema namespace with flp prefix as the rest of the XML:

    XmlElement D100 = doc.CreateElement("flp", "D100", "http://www.w3.org/2001/XMLSchema");
    

    Lastly: http://www.w3.org/2001/XMLSchema is a standard namespace, that here is used for some custom XML, this is in general wrong.

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

Sidebar

Related Questions

I have an XML file containing seed data that I'm trying to load into
I have a weird XML file that I'm trying to parse. <Data> <Row> <Field
I have a List<Item> collection that I am trying to generate an xml file
I have an XML that looks the Below. I am trying to fill a
I have an XML file that I am trying to parse with Sax (this
I have an xml file likes below. <?xml version=1.0 encoding=utf-8 ?> <Book> <Title>Title</Title> <Content>Content</Content>
I have a xml file as below: <?xml version=1.0 encoding=UTF-8 standalone=no?> <RULES> <RULE DESCRIPTION=
I have a long xml file the content of the file are below: <?xml
How do I change my XML file below to have CAS return to the
I have a flat structured XML file as below: <rs> <r id=r1 lev=0/> <r

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.