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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T17:44:45+00:00 2026-05-23T17:44:45+00:00

I am populating textboxes with information from a particular node based on it’s ConfirmNum

  • 0

I am populating textboxes with information from a particular node based on it’s ConfirmNum. Then when all info is updated, I am saving information (by a submit button) back to the particular node.

However, upon saving, every node in the XML file that was empty drops down to another line.

Example XML Before Save:

<OnlineBanking>
  <Transactions>
    <Txn>
      <Login></Login>
      <UserName>userName</UserName>
      <CustomerName>CustomerName</CustomerName>
      <ConfirmNum>1234</ConfirmNum>
    </Txn>
  </Transactions>
</OnlineBanking>

My code (below) will save the information for that node, based on the Page.aspx?CID=1234 number. However, every node in the entire XML file that was blank, will now have a line break in it. Not just the Txn we just edited, but all.

Here is my code:

protected void btnSubmit_Click(object sender, EventArgs e)
{
    XmlDocument item = new XmlDocument();
    item.Load(xmlFileName);
    if (CID != "")
    {
        XmlNode xlist = item.SelectSingleNode("OnlineBanking/Transactions/Txn[ConfirmNum=" + CID + "]");
        if (xlist != null)
        {
            xlist.ChildNodes.Item(0).InnerText = tbLogin.Text;
            xlist.ChildNodes.Item(1).InnerText = tbUserName.Text;
            xlist.ChildNodes.Item(2).InnerText = tbCustomerName.Text;
            item.Save(xmlFileName);
        }
    }
}

Example XML After Save:

<OnlineBanking>
  <Transactions>
    <Txn>
      <Login>
      </Login>
      <UserName>userName</UserName>
      <CustomerName>CustomerName</CustomerName>
      <ConfirmNum>1234</ConfirmNum>
    </Txn>
  </Transactions>
</OnlineBanking>

Note how the <login> is on another line than </login>. This is what I am talking about. Hope someone can see clearly what I am not doing.

  • 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-23T17:44:46+00:00Added an answer on May 23, 2026 at 5:44 pm

    Try setting the PreserveWhitespace property to True and see if it will stop inserting line breaks upon calling Save:

    XmlDocument item = new XmlDocument();
    item.PreserveWhitespace = true;
    item.Load(xmlFileName);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am populating a combobox dropdown with node fields from an Xml document. I
Im populating a GridView from List so am forced to use TemplateField controls to
I'm populating a ListView with items and add images from an ImageList (in the
I'm dynamically populating a ControlPanel with some controls... Some are DropDowns, some are TextBoxes:
I am populating a listbox with a large list. The user then has the
I have an ASP.NET DataTable which I am populating from another set of ASP:TextBox
I have a GView and I am populating rows from code behind. However, in
I am populating a DataTable and then binding this to a GridView control. However,
I'm populating a TreeView with nodes based on an XML document. However, it seems
Quite a common use case, it seems, is when re-populating an object from a

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.