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.
There is all OK with xml parsing in your solution. What you need is processing of
Qualitystrings.What happened here:
+chars to get array of string parts"something". If yes, then it will beor,andor other connective wordBTW you can parse Xml in one line: