XML Snippet
<GameList>
<Game>
<GameDefinitiongameID>{1b2e4ff7-ddd3-4fe3-9fdf-6b2ee240d18c}</GameDefinitiongameID>
<WMID>{01bc5c01-923d-4efb-bba6-49e93b2694ab}</WMID>
<VersionNumberversionNumber>1.0.0.0</VersionNumberversionNumber>
<Title>JamesBond007:Nightfire</Title>
<GameExecutablepath>\easupport\go_ez.exe</GameExecutablepath>
<GameExecutablepath>\easupport\jamesbond007nightfire_code.exe</GameExecutablepath>
<GameExecutablepath>\easupport\jamesbond007nightfire_ereg.exe</GameExecutablepath>
<GameExecutablepath>\easupport\jamesbond007nightfire_ez.exe</GameExecutablepath>
<GameExecutablepath>jamesbond007nightfire_uninst.exe</GameExecutablepath>
<GameExecutablepath>unwise.exe</GameExecutablepath>
<RatingratingID>{CEC5DB5A-B4C9-4809-96C6-39CE715E4790}</RatingratingID>
<ratingSystemID>{36798944-B235-48ac-BF21-E25671F597EE}</ratingSystemID>
<DescriptordescriptorID>{F110F831-9412-40c9-860A-B489407ED374}</DescriptordescriptorID>
<RatingratingID>{18CD34B7-7AA3-42b9-A303-5A729B2FF228}</RatingratingID>
<ratingSystemID>{768BD93D-63BE-46A9-8994-0B53C4B5248F}</ratingSystemID>
<DescriptordescriptorID>{B54162A2-F67F-46dc-9ED5-F6067520EC94}</DescriptordescriptorID>
<DescriptordescriptorID>{BE562A5F-2A80-4c28-9752-74C696E2ABAF}</DescriptordescriptorID>
</Game>
and so on.
I used the following to query this file
Dim members = From m In GameXml.Element("GameList").Elements("Game")
Where m.Element("Title").Value.ToLower.Contains(Name) = True
Select m.Descendants
"Name" is the variable containing the search string.
Now, how to I get all the info (as array of strings or any other parse-able format) from the "members" variable.
I am new to XML and LINQ.
I am OK with both C# and VB.Net.
If you don't know what exact properties it has you can do this:
dynamic members = from m In GameXml.Element("GameList").Elements("Game")
where m.Element("Title").Value.ToLower.Contains(Name) = True
select m;
now you can use: members.ratingSystemID
But if you know the properties you can create a class like:
public class Game{
public string Title{set; get; }
public string Name {get; set;}
.
.
.
}
and then:
List<Game> members = from m In GameXml.Element("GameList").Elements("Game")
where m.Element("Title").Value.ToLower.Contains(Name) = True
select new {Title = m.Title, Name = m.Name, ...};
so you can use it like Members[0].Title
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments