0
Ich muss alle Werte basierend auf untergeordneten Elementwert gruppieren. Im Folgenden finden Sie Beispiel meiner XMLASP.Net VB - Linq zu XML-Gruppe von Kind Element Wert
<Matchday date="2016-05-09">
<Match id="1288348">
<Home id="13" name="club1"/>
<Away id="14" name="club2"/>
<Information>
<country>England</country>
</Information>
</Match>
<Match id="1288349">
<Home id="15" name="club3"/>
<Away id="16" name="club4"/>
<Information>
<country>England</country>
</Information>
</Match>
<Match id="1288350">
<Home id="17" name="club5"/>
<Away id="18" name="club6"/>
<Information>
<country>Italy</country>
</Information>
</Match>
<Match id="1288351">
<Home id="19" name="club7"/>
<Away id="20" name="club8"/>
<Information>
<country>Spain</country>
</Information>
</Match>
</Matchday>
ich nach Land gruppieren will, so wird das Ergebnis so aussehen:
England
1288348
1288349
Italy
1288350
Spain
1288351
Wie dies mit vb Linq von Code-Behind zu XML-Abfrage zu tun.
Dank
danke, Sie Code funktioniert gut, aber ich musste Ihre Anfrage ein wenig beheben. Dies ist die Arbeitsabfrage: Dim matchGroup = Von mG In xe.Descendants.Elements ("Spieltag"). Elemente ("Match"). GroupBy (Funktion (x) x.Element ("Information"). Element ("Land")) .Wert) Wählen Sie mG – Robert
Was ist 'xe' in Ihrem Code? Wenn es ein 'XDocument' ist, verwenden Sie' x.Root' anstelle von 'xe.Descendants()'. Ersteres wäre viel effizienter. – har07
Ich habe das vergessen, Dim xe als XElement = XElement.Load (Server.MapPath ("exporter.xml")) – Robert