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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T21:47:56+00:00 2026-06-10T21:47:56+00:00

So, below I made a code which lists my 2 items in comboBox1 by

  • 0

So, below I made a code which lists my 2 items in comboBox1 by its name(Selena and Maria) on load, and when I select one of those, lets say Maria, and click on button1, it populates my 3 textboxes with Maria’s name,usn and pawd attribute values, and it looks like:
Display name: Maria
Username: mary26
Password: d4e5r

and I am happy with that part of code, because it serves my purpose.

But I am struggling with part of code which I am trying to figure out.
I created a button2, and I would like that, when I change values of Display name, Username or Password textboxes, and I click save, that it saves to right location in xml file, to Maria, and does not save it to Selena or something else.

I have tried browsing for a week now, and multiple solutions, and I couldn’t find any.

att.xml:

<database>
<item name="Selena" usn="sele22" pawd="fed47a"></item>
<item name="Maria" usn="mary26" pawd="d4e5r"></item>
<database>

myproject:

private void Form3_Load(object sender, EventArgs e)
        {
            comboBox1.Items.Clear();
            XmlTextReader reader = new XmlTextReader("att.xml");
            while (reader.Read())
            {
                if (reader.NodeType == XmlNodeType.Element)
                {
                    if (reader.Name == "item")
                    {
                        comboBox1.Items.Add(reader.GetAttribute("name"));
                    }
                }
            }

            reader.Close();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            string secit = comboBox1.SelectedItem as string;
            XmlTextReader lola = new XmlTextReader("att.xml");
            while (lola.Read())
            {
                if (lola.NodeType == XmlNodeType.Element)
                {
                    string poop = lola.GetAttribute("name"); 
                    if (poop == secit) 
                    {
                        string username = lola.GetAttribute("usn"); 
                        string password = lola.GetAttribute("pawd");
                        string dispname = lola.GetAttribute("name");

                        textBox1.Text = dispname;
                        textBox2.Text = username;
                        textBox3.Text = password;

                    }
                }
            }

            lola.Close();
        }
  • 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-10T21:47:57+00:00Added an answer on June 10, 2026 at 9:47 pm

    You can use XmlDocument like this:

    XmlDocument doc = new XmlDocument();
    doc.Load("att.xml");
    foreach(XmlNode item in doc.SelectNodes("//item"))
        comboBox1.Items.Add(item.Attributes["name"].Value);
    
    
    void button3_Click(object sender, NotifyArgs e)
    {
        XmlNode item = doc.SelectSingleNode("//item[@name='" + comboBox1.Text + "']");
        if (item == null) return;
        item.Attributes["name"].Value = textBox1.Text;
        ...
        doc.Save("att.xml");
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have made a YUI module a little like the code shown below, which
I've made a simple benchmark code for redis as below pseudocode. for 10~100 redis
Below is my form. Using jQuery I load a <select> element based on value
Consider the code below (which has been simplified). I have a service class that
I have made some code which exports some details of a journal article to
I have the below SQL which works just fine: SELECT Message, CreateDate, AccountId, AlertTypeId
Below is code to an inherited ComboBox. The issue is that the ComboBox is
Below is the code from internalRegister method of GCMRegistrar class static void internalRegister(Context context,
below is the code to download a txt file from internet approx 9000 lines
Below is the code from a plugin I use for sitemaps. I would like

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.