/// <summary> /// Closes all elements that are open back to the last /// start tag for this element. Returns true if the /// matching tag is found and element(s) are closed. IF /// no matching tag is found, no tags are closed and the /// method returns false. /// </summary> private bool CloseBackToMatchingTag(string name) { // Find last-previous open var index = openElements.IndexOf(name); // No prior matching tag, so do nothing if (index == -1) { return(false); } // Close open elements back to last-previous open CloseOpenElements(openElements.Count - index); return(true); }