internal bool DecideXPNodeTypeForTextNodes(XmlNode node, ref XPathNodeType xnt) { //returns true - if all siblings of the node are processed else returns false. //The reference XPathNodeType argument being passed in is the watermark that //changes according to the siblings nodetype and will contain the correct //nodetype when it returns. XmlNode?n = node; Debug.Assert(XmlDocument.IsTextNode(n.NodeType) || (n.ParentNode != null && n.ParentNode.NodeType == XmlNodeType.EntityReference)); while (n != null) { switch (n.NodeType) { case XmlNodeType.Whitespace: break; case XmlNodeType.SignificantWhitespace: xnt = XPathNodeType.SignificantWhitespace; break; case XmlNodeType.Text: case XmlNodeType.CDATA: xnt = XPathNodeType.Text; return(false); case XmlNodeType.EntityReference: if (!DecideXPNodeTypeForTextNodes(n.FirstChild !, ref xnt)) { return(false); } break; default: return(false); } n = n.NextSibling; } return(true); }