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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T10:18:59+00:00 2026-05-24T10:18:59+00:00

How can I write inside an xml file using c# and the xmldocument or

  • 0

How can I write inside an xml file using c# and the xmldocument or xpathnavigator class. I want to write a node inside of three entries. As an example, I want to write a “window” entry a few times..

<tabpage>
      <form>
         <Window>
             <.....>name<...>
             <.....>age<.....>
             <.....>gender<..>
         </Window>
         <Window>
             <.....>name<...>
             <.....>age<.....>
             <.....>gender<..>
         </Window>
      </form>
 <tabpage>              
  • 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-24T10:19:00+00:00Added an answer on May 24, 2026 at 10:19 am

    you can use something like the following:

    string targetFileName = "";
    string[] myWindows = new string[];
    
    using (XmlTextWriter oXmlTextWriter = new XmlTextWriter(targetFileName , Encoding.UTF8))
    {
      oXmlTextWriter.Formatting = Formatting.Indented;
      oXmlTextWriter.WriteStartDocument();
      oXmlTextWriter.WriteStartElement("tabpage");
      oXmlTextWriter.WriteStartElement("form");
    
      foreach( string window in myWindows)
      {
         oXmlTextWriter.WriteStartElement("Window");
    
         oXmlTextWriter.WriteElementString("name", nameValue);
         oXmlTextWriter.WriteElementString("age", nameValue);
         oXmlTextWriter.WriteElementString("gender", nameValue);
    
         oXmlTextWriter.WriteEndElement(); // closing Window tag
      }
      oXmlTextWriter.WriteEndElement(); // closing form tag
      oXmlTextWriter.WriteEndElement(); // closing tabpage tag
    
      // closing the XML file
      oXmlTextWriter.WriteEndDocument();
      oXmlTextWriter.Flush();
      oXmlTextWriter.Close();
    }
    

    obviously you should change the above code snippet to fit to your specific XML you want to generate. you also didn’t provide much information what should be inside a window XML element – do you plan to write XML attributes per window or sub XML elements describing name/age/gender information.

    you can see many more examples in MSDN – go to http://msdn.microsoft.com and search from XmlTextWriter.

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

Sidebar

Related Questions

Im using aspxGridView control. It has templates inside. In aspx file I can write
Can i write bytecode inside a method of a class so that the compiler
I need to generate an XML file in C#. I want to write the
I need to read XML file and store all the info inside variables/class when
I can write: update my_table set xml = updateXML(xml, '/a/b', '1') where document_id =
I have an XML file with some CDATA nodes. I want to change the
Is there a way to include a File Content inside the Class ,not just
I am using DOM representations in java how can I distinguish if an xml
Editing to specify more clearly the scenario. I have to write a xml file,
I have an xml file inside the res folder under the xml forlder. I

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.