Thursday 15 May 2014

c# - LINQ to XML subquery to ListBox -


I have an XML file that looks like this:

    

I have XML queries from LINQ, which has helped me with some help.

  var query3 = (in xDoc.Descendants select c ("script") new {name = (string) c.Element ("name"). Value, author = (string ) C.Element ("author"). Value, // destination = c.Element ("fileDestination") elements (). (E => (string) c.Element ("destination"). Value) // Destination = c.Element ("fileDestination"). Elements (). Where (E => (value = null). Selection (E => (string) c.Element ("Destination"). Value) .list () Destination = c.Descendants ("fileDestination" Elements (.) Element ("File Destination"). Choose Element ("Destination") Value! = Faucet). (E => (string ) C.Element ("destination"). Value);) The problem is that, (1) I always get a redundant panic and (2) I do not understand how to use the results of the second selection I can do something like this:  
  txtScriptTitle.Text = query.FirstOrDefault () .name; CmboAuthor.Text = query.FirstOrDefault (). Author;   

To show the results of the first two items, but I do not know how to reach "destination".

Force a single query against XML document and a single result in the individual text boxes (txtName and txtAuthor) (name and author in my example below), and then a list Tie sub-class results in the box. Can I do this in a single question?

is trying to change its query which is from destination to

  destination = c.Descendants ("destination"). Choose (E = & gt; E. Well). Where (S => String.IsNullOrEmpty (s)) to create a list ();   

It will populate with the list that you can then tie in your control.

No comments:

Post a Comment