XElement student = new XElement("Student", new XElement("Name", "John"), new XElement("Age", "22") ); string name = student.GetElementValue("Name"); Console.WriteLine("Student Name: " + name);
XElement root = XElement.Parse("In this example, we parse an XML string and create an XElement object named "root". We then use the Element method to navigate to the "Course" element and then to the "Lecturer" element, and finally we use the GetElementValue method to extract the value of the "Lecturer" element. The extracted value is then printed using the Console.WriteLine method. The package library used in these examples is System.Xml.Linq."); string lecturer = root.Element("Course").Element("Lecturer").GetElementValue(); Console.WriteLine("Lecturer: " + lecturer); John