LINQ to XML

Z

zino

in a silverlight application I have a function that receive the xml string as :
dim str as string="<root>
<history name="a" />
<history name="b" />
<history name="c" >
<docs type="pdf" Id="7" />
</history>
<history name="d">
<docs type="excel" Id="8" />
</history>
</root>"


dim xDoc As XDocument = XDocument.Parse(str)
dim myList = From d In xDoc.Descendants("root") _
Select New myClass _
With {.Id = d...<docs>.@Id, .Type =
d...<docs>.@type}

myGrid.ItemsSource = myList


class myClass
Private _Id As String
Private _type As String

property Id() As String
....... ....
end property


property Type() As String
....... ....
end property

end class


the problem is: myList contains only the first <docs> element, but I need
all the <docs> element and not only the first one

how can I do that?
 
Z

zino

as a follow up, I meant, is there a way to get all docs elements without
looping through all of them (without FOR EACH)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top