creates a ``PrimaryTextNode`` instance from the etree representation of
        a <nodes> element from a SaltXMI file.
483742
def from_etree(cls, etree_element):
        
        ins = SaltNode.from_etree(etree_element)
        # TODO: this looks dangerous, ask Stackoverflow about it!
        # convert SaltNode into PrimaryTextNode
        ins.__class__ = PrimaryTextNode.mro()[0]
        ins.text = extract_primary_text(etree_element)
        return ins
1086393
def GetElementNSdict(self, elt):
        '''
        '''
        d = self.ns_cache.get(id(elt))
        if not d:
            if elt != self.dom: d = self.GetElementNSdict(elt.parentNode)
            for a in _attrs(elt):
                if a.namespaceURI == XMLNS.BASE:
                    if a.localName == "xmlns":
                        d[''] = a.nodeValue
                    else:
                        d[a.localName] = a.nodeValue
            self.ns_cache[id(elt)] = d
        return d.copy()
984501
def convert_to_node(instance, xml_node: XmlNode, node_globals: InheritedDict = None)\
    -> InstanceNode:
    ''''''
    return InstanceNode(instance, xml_node, node_globals)
538969
def create_node(xml_node: XmlNode, **init_args):
    ''''''
    inst_type = get_inst_type(xml_node)
    init_args['xml_node'] = xml_node
    inst = create_inst(inst_type, **init_args)
    if not isinstance(inst, Node):
        inst = convert_to_node(inst, **init_args)
    return inst
397840
def serialize(self, node):
        """"""
        if isinstance(node.tag, types.FunctionType):
            # this looks like a bug of ElementTree: comments are stored as
            # functions!?? see https://hg.python.org/sandbox/python2.7/file/tip/Lib/xml/etree/ElementTree.py#l458
            return
        if self.nsmap is not None:
            tag = self.shorten(node.tag)
        else:
            tag = node.tag
        with warnings.catch_warnings():  # unwanted ElementTree warning
            warnings.simplefilter('ignore')
            leafnode = not node
        # NB: we cannot use len(node) to identify leafs since nodes containing
        # an iterator have no length. They are always True, even if empty :-(
        if leafnode and node.text is None:
            self.emptyElement(tag, node.attrib)
            return
        self.start_tag(tag, node.attrib)
        if node.text is not None:
            txt = escape(scientificformat(node.text).strip())
            if txt:
                self._write(txt)
        for subnode in node:
            self.serialize(subnode)
        self.end_tag(tag)
47521
def from_elements(cls, elts=None):
        
        node = cls()
        if elts is None:
            node.elts = []
        else:
            node.elts = [const_factory(e) if _is_const(e) else e for e in elts]
        return node
733396
def docx_text_from_xml(xml: str, config: TextProcessingConfig) -> str:
    
    root = ElementTree.fromstring(xml)
    return docx_text_from_xml_node(root, 0, config)
815980
def to_element(self, root_name=None):
        """"""
        if not root_name:
            root_name = self.nodename
        elem = ElementTreeBuilder.Element(root_name)
        for attrname in self.serializable_attributes():
            # Only use values that have been loaded into the internal
            # __dict__. For retrieved objects we look into the XML response at
            # access time, so the internal __dict__ contains only the elements
            # that have been set on the client side.
            try:
                value = self.__dict__[attrname]
            except KeyError:
                continue

            if attrname in self.xml_attribute_attributes:
                elem.attrib[attrname] = six.text_type(value)
            else:
                sub_elem = self.element_for_value(attrname, value)
                elem.append(sub_elem)

        return elem
255102
function createTextNode (type, item) {
      var node = parser.createTextNode(type, item.surface_form)

      if (options && options.pos) {
        node.data = item
      }

      return node
    }
691058
def xml_to_root(xml: Union[str, IO]) -> ElementTree.Element:
    
    if isinstance(xml, str):
        if '<' in xml:
            return ElementTree.fromstring(xml)
        else:
            with open(xml) as fh:
                xml_to_root(fh)
    tree = ElementTree.parse(xml)
    return tree.getroot()
415298
private void emitNode() throws TTIOException {
        switch (mRtx.getNode().getKind()) {
        case ROOT:
            mEvent = mFac.createStartDocument();
            break;
        case ELEMENT:
            final long key = mRtx.getNode().getDataKey();
            final QName qName = mRtx.getQNameOfCurrentNode();
            mEvent = mFac.createStartElement(qName, new AttributeIterator(mRtx), new NamespaceIterator(mRtx));
            mRtx.moveTo(key);
            break;
        case TEXT:
            mEvent = mFac.createCharacters(mRtx.getValueOfCurrentNode());
            break;
        default:
            throw new IllegalStateException("Kind not known!");
        }
    }
836575
function( includeSelf, ignoreTextNode ) {
			var start = this.startContainer,
				end = this.endContainer,
				ancestor;

			if ( start.equals( end ) ) {
				if ( includeSelf && start.type == CKEDITOR.NODE_ELEMENT && this.startOffset == this.endOffset - 1 )
					ancestor = start.getChild( this.startOffset );
				else
					ancestor = start;
			} else {
				ancestor = start.getCommonAncestor( end );
			}

			return ignoreTextNode && !ancestor.is ? ancestor.getParent() : ancestor;
		}
81539
def __init_xml(self, rootElementTag):
        """"""
        xml_root = etree.Element(rootElementTag)
        key = etree.SubElement(xml_root, "Key")
        key.text = self.apikey
        return xml_root
727780
def from_etree(
    el, node=None, node_cls=None,
    tagsub=functools.partial(re.sub, r'\{.+?\}', ''),
    Node=Node):
    '''
    '''
    node_cls = node_cls or Node
    if node is None:
        node = node_cls()
    tag = tagsub(el.tag)
    attrib = dict((tagsub(k), v) for (k, v) in el.attrib.items())
    node.update(attrib, tag=tag)

    if el.text:
        node['text'] = el.text
    for child in el:
        child = from_etree(child, node_cls=node_cls)
        node.append(child)
    if el.tail:
        node['tail'] = el.tail
    return node
582139
def parse_root(raw):
    ""
    if sys.version < '3':
        fp = StringIO(raw)
    else:
        fp = BytesIO(raw.encode('UTF-8'))
    for event, element in etree.iterparse(fp, events=('start',)):
        return (element.tag, element.attrib)
555120
def internal_to_elem(pfsh, factory=ET.Element):

    

    attribs = {}
    text = None
    tail = None
    sublist = []
    tag = list(pfsh.keys())
    if len(tag) != 1:
        raise ValueError("Illegal structure with multiple tags: %s" % tag)
    tag = tag[0]
    value = pfsh[tag]
    if isinstance(value, dict):
        for k, v in list(value.items()):
            if k[:1] == "@":
                attribs[k[1:]] = v
            elif k == "#text":
                text = v
            elif k == "#tail":
                tail = v
            elif isinstance(v, list):
                for v2 in v:
                    sublist.append(internal_to_elem({k: v2}, factory=factory))
            else:
                sublist.append(internal_to_elem({k: v}, factory=factory))
    else:
        text = value
    e = factory(tag, attribs)
    for sub in sublist:
        e.append(sub)
    e.text = text
    e.tail = tail
    return e
1032984
def add_from_xmlnode(self, element):
        """"""
        if self.tree is None:
            root = ET.Element('interface')
            root.append(element)
            self.tree = tree = ET.ElementTree(root)
            self.root = tree.getroot()
            self.objects = {}
            # ET.dump(tree)
        else:
            # TODO: append to current tree
            pass