Пример #1
0
        public List <XmlNode> FindElements(string xPath, Hashtable attributes = null)
        {
            XmlNodeList    nodeList = R_RootElement.SelectNodes(xPath);
            List <XmlNode> tempList = new List <XmlNode>();

            foreach (XmlNode item in nodeList)
            {
                if (item is XmlElement)
                {
                    if (attributes != null)
                    {
                        if (item.Attributes != null && item.Attributes.Count > 0)
                        {
                            bool isEquals = true;
                            foreach (DictionaryEntry attr in attributes)
                            {
                                XmlAttribute value = item.Attributes[attr.Key.ToString()];
                                if (value == null)
                                {
                                    isEquals = false;
                                    continue;
                                }
                                else if (value.Value != attr.Value.ToString())
                                {
                                    isEquals = false;
                                    continue;
                                }
                            }
                            if (isEquals)
                            {
                                tempList.Add(item);
                            }
                        }
                    }
                    else
                    {
                        tempList.Add(item);
                    }
                }
            }
            return(tempList);
        }
Пример #2
0
        public List <XmlNode> GetElements(string xPath)
        {
            XmlNodeList    nodeList = R_RootElement.SelectNodes(xPath);
            List <XmlNode> tempList = new List <XmlNode>();

            foreach (XmlNode item in nodeList)
            {
                if (item is XmlElement)
                {
                    tempList.Add(item);
                }
                else
                {
                    if (!_ignoreComments)
                    {
                        tempList.Add(item);
                    }
                }
            }
            return(tempList);
        }