Example #1
0
        public void Parse()
        {
            foreach (var xElement in  XDoc.Descendants("db").Descendants("Groups"))
            {
                    foreach (var xxElement in xElement.Descendants("id"))
                    {
                        _groupId = int.Parse(xxElement.Value);
                    }

                    foreach (var xxElement in xElement.Descendants("Description"))
                    {
                        _description = xxElement.Value;
                    }

                    Groups[_groupsQuant] = new Group(_groupId, _description);
                    _groupsQuant++;
            }

            foreach (var xElement in XDoc.Descendants("db").Descendants("Students"))
            {
                foreach (var xxElement in xElement.Descendants("id"))
                {
                    _studentId = int.Parse(xxElement.Value);
                }

                foreach (var xxElement in xElement.Descendants("group_id"))
                {
                    _studentGroupId = int.Parse(xxElement.Value);
                }
                foreach (var xxElement in xElement.Descendants("stud_name"))
                {
                    _name = xxElement.Value;
                }

                foreach (var xxElement in xElement.Descendants("enroll_year"))
                {
                    _enrollYear = int.Parse(xxElement.Value);
                }
                _students[_studentsQuant]=new Student(_studentId,_studentGroupId,_name,_enrollYear);
                _studentsQuant++;
            }
        }
Example #2
0
        public void Parse()
        {
            Console.WriteLine("Парсинг");
            Console.WriteLine("---------------------");
            foreach (var xElement in XDoc.Descendants("group").Where(xElement => xElement.HasAttributes))
            {
                if (xElement.Attribute("id") != null)
                {
                    group_id = int.Parse(xElement.Attribute("id").Value);
                }

                if (xElement.Attribute("description") != null)
                {
                    description = xElement.Attribute("description").Value;

                }
                Groups[groups_quant] = new Group(group_id,description);
                groups_quant++;
            }
            foreach (XElement xElement in XDoc.Descendants("student").Where(xElement => xElement.HasAttributes))
            {
                if (xElement.Attribute("id") != null)
                {
                    student_id = int.Parse(xElement.Attribute("id").Value);
                }
                if (xElement.Attribute("groupid") != null)
                {
                    student_group_id = int.Parse(xElement.Attribute("groupid").Value);
                }
                if (xElement.Attribute("name") != null)
                {
                    name = xElement.Attribute("name").Value;
                }
                if (xElement.Attribute("year") != null)
                {
                    enroll_year = int.Parse(xElement.Attribute("year").Value);
                }
                Students[students_quant] = new Student(student_id, student_group_id, name, enroll_year);
                students_quant++;
            }
        }