Esempio n. 1
0
        //TODO 重写document.getElementById
        //private void GetElementByIdExt(string id, XmlNode node, ref XmlElement element)
        //{
        //    if (element != null) return;
        //    if (element == null && node.Attributes != null)
        //    {
        //        foreach (XmlAttribute item in node.Attributes)
        //        {
        //            if (item.Name == "id" && item.Value == id)
        //            {
        //                element = item.OwnerElement;
        //                return;
        //            }
        //        }
        //    }
        //    if (element == null)
        //    {
        //        GetElementByIdExt_2(id, node, ref element);
        //    }
        //    //return element;
        //}
        //private void GetElementByIdExt_2(string id, XmlNode node, ref XmlElement element)
        //{
        //    if (element == null)
        //    {
        //        if (node.ChildNodes.Count > 0)
        //        {
        //            foreach (XmlNode item in node.ChildNodes)
        //            {
        //                if (element != null) return;
        //                if (element == null)
        //                {
        //                    GetElementByIdExt(id, item, ref element);
        //                }

        //            }
        //        }
        //    }
        //}

        public virtual IList <IDomElement> GetElementsByNameNs(string namespaceUri, string localName)
        {
            lock (_document)
            {
                XmlNodeList elementsByTagNameNs = _document.GetElementsByTagName(localName, namespaceUri);
                return(DomUtil.FilterNodeListByName(elementsByTagNameNs, namespaceUri, localName));
            }
        }
Esempio n. 2
0
 public virtual IList <IDomElement> GetChildElementsByNameNs(string namespaceUri, string elementName)
 {
     lock (_document)
     {
         XmlNodeList childNodes = _element.ChildNodes;
         return(DomUtil.FilterNodeListByName(childNodes, namespaceUri, elementName));
     }
 }