Usomg Linq to select multiple types of object
-
I am using LINQ To XSD to parse through an SVG XML file. var s = svg.Load("rect.xml"); In order to select all rect objects i do var q = from x in s.rect select new { x }; In order to select all circle objects i do var q = from x in s.circle select new { x }; Can you tell me a query which would give me both rect and circle objects simultaneously. Thanks in Advance [Smile]
-
I am using LINQ To XSD to parse through an SVG XML file. var s = svg.Load("rect.xml"); In order to select all rect objects i do var q = from x in s.rect select new { x }; In order to select all circle objects i do var q = from x in s.circle select new { x }; Can you tell me a query which would give me both rect and circle objects simultaneously. Thanks in Advance [Smile]
var s = XDocument.Load("rect.xml"); var q = from x in s.Descendants() select new { x }; XNamespace ns = "http://tempuri.org/svg11-flat-20030114"; foreach (var itm in q) { if (itm.x.Name == ns + "rect") { rect re = (rect)itm.x; Console.WriteLine(itm.x.Name.ToString()); } if (itm.x.Name == ns + "desc") { rect re = (rect)itm.x; Console.WriteLine(itm.x.Name.ToString()); } }