XDocument xDoc = XDocument.Load(Server.MapPath("Employees.xml")); var name = from nm in xDoc.Root.Elements("Employee") select nm; foreach (XElement xEle in name) { Response.Write(xEle); }
XElement xelement = XElement.Load(Server.MapPath("Employees.xml")); var name = from nm in xelement.Elements("Employee") select nm; foreach (XElement xEle in name) { Response.Write(xEle); }
XElement xelement = XElement.Load(Server.MapPath("Employees.xml")); var name = from nm in xelement.Elements("Employee") select nm.Elements("Name"); foreach (XElement xEle in name) { Response.Write(xEle); }
XElement xelement = XElement.Load(Server.MapPath("Employees.xml")); var name = from nm in xelement.Elements("Employee") select nm.Elements("Address").Element("Zip"); OR var name = from nm in xelement.Elements("Employee") let zips = nm.Elements("Address").Element("Zip") select zips; foreach (XElement xEle in name) { Response.Write(xEle); }
XElement xelement = XElement.Load(Server.MapPath("Employees.xml")); var name = from nm in xelement.Elements("Employee") orderby (string)nm.Element("Address").Element("Zip") descending select nm; foreach (XElement xEle in name) { Response.Write(xEle.Element("Address").Element("Zip").Value); ; }
XElement xelement = XElement.Load(Server.MapPath("Employees.xml")); var name = from nm in xelement.Elements() where (string)nm.Element("Sex") == "Male" select nm; // Only Male Records come foreach (XElement xEle in name) { Response.Write(xEle); // Here you get full xml element of the male persone //Response.Write(xEle.Element("Name")); // Here you get only name of the male persone }