CSharp examples for System.Xml:XML Element
Gets the next XML element of a given element, ignoring any non-element nodes
using System.Xml.Linq; using System.Linq; using System.Collections.Generic; public class Main{ /// <summary> /// Gets the next element of a given element, ignoring any non-element nodes /// </summary> /// <param name="element"></param> /// <returns></returns> public static XElement NextSibling(XElement element) {//from w w w. j a va 2 s .co m XNode siblingNode = element; siblingNode = siblingNode.NextNode; while (siblingNode != null && siblingNode as XElement == null) { siblingNode = siblingNode.NextNode; } return siblingNode as XElement; } }