internal static void ConsumeElementOfDepth(this XmlReader xmlReader, int endElementDepth)
{
int enteringReaderDepth = xmlReader.Depth;
if (enteringReaderDepth < endElementDepth)
{
return;
}
if (enteringReaderDepth == endElementDepth)
{
// Move to the following element
xmlReader.Read();
}
while (xmlReader.Depth > endElementDepth && xmlReader.Read()) { }
if (xmlReader.NodeType == XmlNodeType.EndElement)
{
// Consume the end element
xmlReader.Read();
}
}