Convert `el` to vector of foregoing elements.

    Attr:
        el (obj): Double-linked HTMLElement instance.

    Returns:
        list: HTMLElements which considered as path from root to `el`.
185611
def el_to_path_vector(el):
    
    path = []
    while el.parent:
        path.append(el)
        el = el.parent

    return list(reversed(path + [el]))
498137
def _grab_xpath(root, xpath, converter=lambda x: x):
    
    elements = root.xpath(xpath)
    if elements:
        return converter(str(elements[0]))
    else:
        return None
30074
def from_element(self, element, defaults={}):
        """"""
        if isinstance(defaults, SvdElement):
            defaults = vars(defaults)
        for key in self.props:
            try:
                value = element.find(key).text
            except AttributeError:  # Maybe it's attribute?
                default = defaults[key] if key in defaults else None
                value = element.get(key, default)
            if value is not None:
                if key in self.props_to_integer:
                    try:
                        value = int(value)
                    except ValueError:  # It has to be hex
                        value = int(value, 16)
                elif key in self.props_to_boolean:
                    value = value.lower() in ("yes", "true", "t", "1")

            setattr(self, key, value)
826
function getLinked(elem, attr) {
		var str = elem.getAttribute(attr);
		if(!str) {return null;}
		var m = str.match(/\(\#(.*)\)/);
		if(!m || m.length !== 2) {
			return null;
		}
		return S.getElem(m[1]);
	}
285044
def md_el(node_type, children=[], meta={}, al=nil)
		if  (e=children.first).kind_of?(MDElement) and 
			e.node_type == :ial then
			if al
				al += e.ial
			else
				al = e.ial
			end
			children.shift
		end 
		e = MDElement.new(node_type, children, meta, al)
		e.doc = @doc
		return e
	end
372615
def toXml(self, xparent=None):
        
        if xparent is None:
            xml = ElementTree.Element('object')
        else:
            xml = ElementTree.SubElement(xparent, 'object')

        xml.set('class', self.__class__.__name__)
        for name, value in self._xmlData.items():
            xprop = ElementTree.SubElement(xml, 'property')
            xprop.set('name', name)
            XmlDataIO.toXml(value, xprop)
        return xml
486801
def _get_el_attributes(lxml_el, ns=None, nsmap=None):
    
    attrs = {}
    for attr, val in lxml_el.items():
        attr = _to_colon_ns(attr, default_ns=ns, nsmap=nsmap)
        attrs[attr] = val
    return attrs
1169290
function (el, type) {
		while (el && el.nodeName.toLowerCase() !== type.toLowerCase()) {
			el = el.parentNode;
		}
		return el;
	}
287590
def child_elements(self, by=By.ID, value=None, el_class=None):
        
        el, selector = define_selector(by, value, el_class)
        return self._init_element(elements.PageElementsList(selector, el))
639495
def tag_from_element(el):
    
    tag = el.tag
    namespace = None
    if tag.startswith('{'):
        # Strip namespace of the form "{namespace}tag"
        namespace,tag = tag[1:].split('}')
    try:
        cls = globals()[tag.title()]
        if not issubclass(cls, TagBase):
            raise KeyError()
    except KeyError:
        raise ValueError("TagBase doesn't have a subclass for '%s'." % tag)
    children = [tag_from_element(c) for c in el]
    tag = cls(*children, **el.attrib)
    tag.text = el.text
    tag.tail = el.tail
    if namespace:
        tag.attrib['xmlns'] = namespace
    return tag
3333
function(el) {

      var text = '';

      for (var i = 0; i < el.childNodes.length; i++) {
          var curNode = el.childNodes[i];
          var whitespace = /^\s*$/;

          if(curNode === undefined) {
            text = "";
            break;
          }

          if (curNode.nodeName === "#text" && !(whitespace.test(curNode.nodeValue))) {
              text = curNode.nodeValue;
              break;
          }
      }

      return text;

    }
936289
def _nav_to_tree(root):
    
    def expath(e, x):
        return e.xpath(x, namespaces=HTML_DOCUMENT_NAMESPACES)
    for li in expath(root, 'xhtml:ol/xhtml:li'):
        is_subtree = bool([e for e in li.getchildren()
                           if e.tag[e.tag.find('}')+1:] == 'ol'])
        if is_subtree:
            # It's a sub-tree and have a 'span' and 'ol'.
            itemid = li.get('cnx-archive-uri', 'subcol')
            shortid = li.get('cnx-archive-shortid')
            yield {'id': itemid,
                   # Title is wrapped in a span, div or some other element...
                   'title': squash_xml_to_text(expath(li, '*')[0],
                                               remove_namespaces=True),
                   'shortId': shortid,
                   'contents': [x for x in _nav_to_tree(li)],
                   }
        else:
            # It's a node and should only have an li.
            a = li.xpath('xhtml:a', namespaces=HTML_DOCUMENT_NAMESPACES)[0]
            yield {'id': a.get('href'),
                   'shortid': li.get('cnx-archive-shortid'),
                   'title': squash_xml_to_text(a, remove_namespaces=True)}
1276158
def _buildElementTree(self,):
        
        t_binder = ctree.Element(self.name)

        for k,v in self.__dict__.items():
            if k not in ('name', 'urls', 'inputs', 'paging') and v :
                t_binder.set(k,v)

        self.etree = t_binder
        return t_binder
1099062
function getTextNodes(el) {
  el = el || document.body

  var doc = el.ownerDocument || document
    , walker = doc.createTreeWalker(el, NodeFilter.SHOW_TEXT, null, false)
    , textNodes = []
    , node

  while (node = walker.nextNode()) {
    textNodes.push(node)
  }
  return textNodes
}
767167
def element_attribs_to_dict(self, element):
        
        return {self.ns+':'+key: val for (key, val) in element.attrib.items()
                if key != add_ns('id')}
923111
def get_elements(parent_to_parse, element_path):
    

    element = get_element(parent_to_parse)

    if element is None or not element_path:
        return []

    return element.findall(element_path)
267954
def elementtree_to_dict(element):
    """"""
    d = dict()
    if hasattr(element, 'text') and element.text is not None:
        d['text'] = element.text

    d.update(element.items())  # element's attributes

    for c in list(element):  # element's children
        if c.tag not in d:
            d[c.tag] = elementtree_to_dict(c)
        # an element with the same tag was already in the dict
        else:
            # if it's not a list already, convert it to a list and append
            if not isinstance(d[c.tag], list):
                d[c.tag] = [d[c.tag], elementtree_to_dict(c)]
           # append to the list
            else:
                d[c.tag].append(elementtree_to_dict(c))
    return d