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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T12:31:39+00:00 2026-06-17T12:31:39+00:00

I have this example code in my c# win form… List<string> listFurniture = new

  • 0

I have this example code in my c# win form…

List<string> listFurniture = new List<string>();
XDocument xml = XDocument.Load(Application.StartupPath + @"\Furniture.xml");
foreach (XElement quality in xml.Descendants("Quality"))
    listFurniture.Add(quality.Value);

maintextbox.Text = listFurniture[0];

… And this example xml

<Furniture>
  <Table>
    <Quality>textbox1.Text + "and" + textbox2.Text + "but" + textbox3.Text</Quality>   
    ...
  </Table>  
</Furniture>

My dilemma is, the maintextbox is producing the actual string “textbox1.Text“, instead of the value of textbox1.

I want the xml value to be read as:

maintextbox.Text = textbox1.Text + "and" + textbox2.Text + "but" + textbox3.Text;

not as:

maintextbox.Text = "textbox1.Text + "and" + textbox2.Text + "but" + textbox3.Text";

I tried using a text file as well with StreamReader and I got the same result.

The reason for coding my project this way is because the sequence of the textboxes changes and so does the “and” and the “but”. When that change happens, I wouldn’t have to rewrite the code and recompile the program. I would just make the changes in xml.

  • 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-17T12:31:40+00:00Added an answer on June 17, 2026 at 12:31 pm

    There is all OK with xml parsing in your solution. What you need is processing of Quality strings.

    string[] parts = quality.Split('+');
    Regex regex = new Regex(@"^""(.*)""$");
    var textBoxes = Controls.OfType<TextBox>().ToList();
    
    for (int i = 0; i < parts.Length; i++)
    {
        string part = parts[i].Trim();
    
        var match = regex.Match(part);
        if (match.Success)
        {
            parts[i] = match.Groups[1].Value;
            continue;
        }
    
        var textBox = textBoxes.FirstOrDefault(tb => tb.Name + ".Text" == part);
        if (textBox != null) // possibly its an error if textbox not found
            parts[i] = textBox.Text; 
    }    
    
    mainTextBox.Text = String.Join(" ", parts);
    

    What happened here:

    • We split quality string by + chars to get array of string parts
    • With regular expression we verify if part looks like something in quotes "something". If yes, then it will be or, and or other connective word
    • And last, we check all textboxes for matching name of textbox in quality string part. If it matches, then we replace part with text from textbox
    • We join parts to get result string

    BTW you can parse Xml in one line:

    var listFurniture = xml.Descendants("Quality") 
                           .Select(q => (string)q)
                           .ToList();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Suppose we have this example: http://techdroid.kbeanie.com/2009/07/custom-listview-for-android.html with source code available here: http://code.google.com/p/myandroidwidgets/source/browse/trunk/Phonebook/src/com/abeanie/ How can
If I have a simple cucumber feature and scenario , like this (example code
I have this code (an example that PHP generates for me)... <select id=outsideBlue3> <option
For example we have this line chart at Google Code API there is a
For example, I have this code: <table> <tr> <td class=last></td> <td></td> </tr> <tr> <td
For Example if i have my code like this (php): <?php somefunc(1); function somefunc($a)
Ok, in my code I have for example, this: $('.follow').click(function(){ var myself = $(this);
I have this struct: Example.Form = Ext.extend(Ext.form.FormPanel, { // other element , onSuccess:function(form, action)
I have used this code (kind of tutorial) at http://code.google.com/p/gwt-examples/wiki/gwt_hmtl5 ... In this code,
I have this example FactoryGirl.define do @site = FactoryGirl.create(:my_site) factory :user do email {

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.