0

I'm not good in ASP.NET(c#) and XML. I have a textbox control, a button, and a website url(ex: http://chelseacole.com/question) has content of a xml file, like this:

<paragraph>
<text att1="1" att2="2">
        facebook, facebook, facebook, facebook.
</text>
<text att1="3" att2="4">
        twitter, twitter, twitter, twitter.
</text>
<text att1="5" att2="6">
        facebook, twitter, facebook, twitter.
</text>
</paragraph>

So what I want is: went I click the button, the result will appear in the textbox control, like this:

facebook, facebook, facebook, facebook.
twitter, twitter, twitter, twitter.
facebook, twitter, facebook, twitter.

Anyone gonna help me? Thanks in advance! :">

Chelsea_cole
  • 1,055
  • 3
  • 15
  • 21

2 Answers2

3

If I've understand what do you want to achieve, try something like this:

XDocument document = XDocument.Load("file.xml");

or:

XDocument document = XDocument.Parse("<paragraph><text att ... ");

foreach (XElement item in document.Descendants("text"))
    textbox.Text+=item.Value + Environment.NewLine;
danyolgiax
  • 12,798
  • 10
  • 65
  • 116
1

You could check this

LINQ to read XML

I would not recommend any other solution than this

Community
  • 1
  • 1
Eric Herlitz
  • 25,354
  • 27
  • 113
  • 157