NodesMatch() static public method

Return true if the two nodes match. Corresponding children should match, and corresponding attributes (though not necessarily in the same order). The nodes are expected to be actually XmlElements; not tested for other cases. Comments do not affect equality.
static public NodesMatch ( XmlNode node1, XmlNode node2 ) : bool
node1 System.Xml.XmlNode
node2 System.Xml.XmlNode
return bool
コード例 #1
0
ファイル: XmlUtils.cs プロジェクト: cambell-prince/FieldWorks
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Find the index of the node in nodes that 'matches' the target node.
        /// Return -1 if not found.
        /// </summary>
        /// <param name="nodes">The nodes.</param>
        /// <param name="target">The target.</param>
        /// <returns></returns>
        /// ------------------------------------------------------------------------------------
        public static int FindIndexOfMatchingNode(IEnumerable <XmlNode> nodes, XmlNode target)
        {
            int index = 0;

            foreach (XmlNode node in nodes)
            {
                if (XmlUtils.NodesMatch(node, target))
                {
                    return(index);
                }
                index++;
            }
            return(-1);
        }