Ejemplo n.º 1
0
        private Element _getElementById(Node topElement, string id)
        {
            if (topElement.nodeType == enumNodeType.ELEMENT)
            {
                Element element = (Element)topElement;

                if (element.hasAttribute("id"))
                {
                    string idvalue = element.getAttribute("id");
                    if (idvalue == id)
                    {
                        return(element);
                    }
                }
            }

            foreach (var item in topElement.childNodes.item)
            {
                Element returnelement = _getElementById(item, id);
                if (returnelement != null)
                {
                    return(returnelement);
                }
            }

            return(null);
        }
Ejemplo n.º 2
0
        private void _getElementByAttribute(Node topElement, HTMLCollection collection, string AttributeName)
        {
            if (topElement.nodeType == enumNodeType.ELEMENT)
            {
                Element element = (Element)topElement;
                if (element.hasAttribute(AttributeName))
                {
                    collection.Add(element);
                }
            }

            foreach (var item in topElement.childNodes.item)
            {
                _getElementByAttribute(item, collection, AttributeName);
            }
        }
Ejemplo n.º 3
0
        private void _getElementByClassName(Node topElement, HTMLCollection collection, string classnames)
        {
            if (topElement.nodeType == enumNodeType.ELEMENT)
            {
                Element element = (Element)topElement;

                if (element.hasAttribute("class"))
                {
                    string classvalue = element.getAttribute("class");

                    if (!string.IsNullOrEmpty(classvalue))
                    {
                        string[] classlist = classnames.Split(' ');

                        bool matched = true;

                        foreach (var item in classlist)
                        {
                            if (!classvalue.Contains(item))
                            {
                                matched = false;
                                break;
                            }
                        }

                        if (matched)
                        {
                            collection.Add(element);
                        }
                    }
                }
            }

            foreach (var item in topElement.childNodes.item)
            {
                _getElementByClassName(item, collection, classnames);
            }
        }