System.Xml.XmlDocument.IsTextNode C# (CSharp) Method

IsTextNode() static private method

static private IsTextNode ( System.Xml.XmlNodeType nt ) : bool
nt System.Xml.XmlNodeType
return bool
        internal static bool IsTextNode(XmlNodeType nt)
        {
            switch (nt)
            {
                case XmlNodeType.Text:
                case XmlNodeType.CDATA:
                case XmlNodeType.Whitespace:
                case XmlNodeType.SignificantWhitespace:
                    return true;
                default:
                    return false;
            }
        }

Usage Example

Example #1
0
        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);
        }