Esempio n. 1
0
        static void Main()
        {
            XElement root = XmlSampleData.GetElement();

            var query = root.Element("users").Elements()
                        .Select(user => new { Name     = (string)user.Attribute("name"),
                                              UserType = (string)user.Attribute("type") });

            foreach (var user in query)
            {
                Console.WriteLine("{0}: {1}", user.Name, user.UserType);
            }
        }
Esempio n. 2
0
        static void Main()
        {
            XElement root = XmlSampleData.GetElement();

            var query = from defect in root.Descendants("defect")
                        join user in root.Descendants("user")
                        on(int?) defect.Attribute("assigned-to") equals
                            (int) user.Attribute("id")
                        join project in root.Descendants("project")
                        on(int) defect.Attribute("project") equals
                            (int) project.Attribute("id")
                        where (string)defect.Attribute("status") != "Closed"
                        select new { ID       = (int)defect.Attribute("id"),
                                     Project  = (string)project.Attribute("name"),
                                     Assignee = (string)user.Attribute("name") };

            foreach (var defect in query)
            {
                Console.WriteLine("{0}: {1}/{2}",
                                  defect.ID,
                                  defect.Project,
                                  defect.Assignee);
            }
        }
Esempio n. 3
0
 static void Main()
 {
     Console.WriteLine(XmlSampleData.GetElement());
 }