LINQ to XML

  • Thread starter Thread starter zino
  • Start date Start date
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?
 
as a follow up, I meant, is there a way to get all docs elements without
looping through all of them (without FOR EACH)
 
Back
Top