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" a开发者_Python百科tt2="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! :">
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;
You could check this
LINQ to read XML
I would not recommend any other solution than this
精彩评论