CSharp examples for System.Xml:XML Element
Select Element by xpath
using System.Xml.Linq; using System.Threading.Tasks; using System.Text; using System.Linq; using System.Collections.Generic; using System;/*ww w . java 2 s . c o m*/ public class Main{ public static XElement SelectElement(XElement doc, string path) { XElement res = null; if (string.IsNullOrEmpty(path)) { return res; } var tracks = path.Split('/'); res = doc.Element(tracks[0]); for (int i = 1; (i < tracks.Length) && (res != null); i++) { res = res.Element(tracks[i]); } return res; } }