コード例 #1
0
        protected virtual bool AreNodeAttributesEqual(XmlAttributeCollection expectedAttributes, XmlAttributeCollection actualAttributes)
        {
            if (expectedAttributes == null && actualAttributes == null)
            {
                return(true);
            }

            if (expectedAttributes == null || actualAttributes == null)
            {
                return(false);
            }

            _xmlnsAttributeFilter.Handle(expectedAttributes);
            _xmlnsAttributeFilter.Handle(actualAttributes);

            if (expectedAttributes.Count != actualAttributes.Count)
            {
                return(false);
            }

            for (int i = 0; i < expectedAttributes.Count; i++)
            {
                if (!AreAttributesEqual(expectedAttributes[i], actualAttributes[i]))
                {
                    return(false);
                }
            }

            return(true);
        }
コード例 #2
0
        public string GetXPathExpression(Stack <XmlNode> nodeStack)
        {
            StringBuilder xPathBuilder = new StringBuilder();

            while (nodeStack.Count > 0)
            {
                XmlNode currentNode = nodeStack.Pop();
                if (currentNode.NodeType == XmlNodeType.Element)
                {
                    _xmlnsAttributeHandler.Handle(currentNode.Attributes);
                    AppendNode(xPathBuilder, currentNode);
                    if (currentNode.NodeType == XmlNodeType.Element)
                    {
                        AppendAttributes(xPathBuilder, currentNode.Attributes);
                    }
                }
            }

            return(xPathBuilder.ToString());
        }