generates an Introspection tree from the given XML string description.
197161
def parse(celf, s) :
        ""

        def from_string_elts(celf, attrs, tree) :
            elts = dict((k, attrs[k]) for k in attrs)
            child_tags = dict \
              (
                (childclass.tag_name, childclass)
                for childclass in tuple(celf.tag_elts.values()) + (Introspection.Annotation,)
              )
            children = []
            for child in tree :
                if child.tag not in child_tags :
                    raise KeyError("unrecognized tag %s" % child.tag)
                #end if
                childclass = child_tags[child.tag]
                childattrs = {}
                for attrname in childclass.tag_attrs :
                    if hasattr(childclass, "tag_attrs_optional") and attrname in childclass.tag_attrs_optional :
                        childattrs[attrname] = child.attrib.get(attrname, None)
                    else :
                        if attrname not in child.attrib :
                            raise ValueError("missing %s attribute for %s tag" % (attrname, child.tag))
                        #end if
                        childattrs[attrname] = child.attrib[attrname]
                    #end if
                #end for
                if hasattr(childclass, "attr_convert") :
                    for attr in childclass.attr_convert :
                        if attr in childattrs :
                            childattrs[attr] = childclass.attr_convert[attr](childattrs[attr])
                        #end if
                    #end for
                #end if
                children.append(from_string_elts(childclass, childattrs, child))
            #end for
            for child_tag, childclass in tuple(celf.tag_elts.items()) + ((), (("annotations", Introspection.Annotation),))[tree.tag != "annotation"] :
                for child in children :
                    if isinstance(child, childclass) :
                        if child_tag not in elts :
                            elts[child_tag] = []
                        #end if
                        elts[child_tag].append(child)
                    #end if
                #end for
            #end for
            return \
                celf(**elts)
        #end from_string_elts

    #begin parse
        tree = XMLElementTree.fromstring(s)
        assert tree.tag == "node", "root of introspection tree must be <node> tag"
        return \
            from_string_elts(Introspection, {}, tree)
918937
@Override
  public void introspect(ContextH3 context)
  {
    if (_infoRef.get() != null) {
      return;
    }
    
    _ctor = introspectConstructor();

    TreeMap<String,FieldSerBase> fieldMap = new TreeMap<>();

    try {
      introspectFields(fieldMap, _type);
    } catch (Exception e) {
      throw new IllegalStateException(e);
    }

    _fields = new FieldSerBase[fieldMap.size()];
    fieldMap.values().toArray(_fields);

    FieldInfoH3[] fieldInfo = new FieldInfoH3[_fields.length];

    for (int i = 0; i < _fields.length; i++) {
      fieldInfo[i] = _fields[i].info(); 
    }

    _infoRef.compareAndSet(null, new ClassInfoH3(_type.getName(), fieldInfo));
  }
723378
def xpath(node, query, namespaces={}):
    """"""
    if namespaces and 'None' not in namespaces:
        return node.xpath(query, namespaces=namespaces)
    return node.xpath(query)
475487
def from_string(cls, xml_string, validate=True):
        
        return xmlmap.load_xmlobject_from_string(xml_string, xmlclass=cls, validate=validate)
587597
def etree_to_string(tree):
        
        buff = BytesIO()
        tree.write(buff, xml_declaration=True, encoding='UTF-8')
        return buff.getvalue()
1150248
def _read_provenance_from_xml(self, root):
        
        path = self._special_properties['provenance']
        provenance = root.find(path, XML_NS)
        for step in provenance.iter('provenance_step'):
            title = step.find('title').text
            description = step.find('description').text
            timestamp = step.get('timestamp')

            if 'IF Provenance' in title:
                data = {}
                from safe.metadata35.provenance import IFProvenanceStep
                keys = IFProvenanceStep.impact_functions_fields
                for key in keys:
                    value = step.find(key)
                    if value is not None:
                        data[key] = value.text
                    else:
                        data[key] = ''
                self.append_if_provenance_step(
                    title, description, timestamp, data)
            else:
                self.append_provenance_step(title, description, timestamp)
867325
def tree_to_xml(self):
        """"""

        # Need to remove filter or hidden items will not be saved.
        self.filter_remove(remember=True)

        tree = self.treeview
        root = ET.Element('interface')
        items = tree.get_children()
        for item in items:
            node = self.tree_node_to_xml('', item)
            root.append(node)

        # restore filter
        self.filter_restore()

        return ET.ElementTree(root)
629925
def fromXml(cls, xml):
        
        clsname = xml.get('class')
        if clsname:
            subcls = XmlObject.byName(clsname)
            if subcls is None:
                inst = MissingXmlObject(clsname)
            else:
                inst = subcls()
        else:
            inst = cls()

        inst.loadXml(xml)
        return inst
124878
def generate_xmltags(fn, returntag, ignore_tags, ns=None):
    
    xmlns = create_namespace(ns)
    ns_ignore = ['{0}{1}'.format(xmlns, x) for x in ignore_tags]
    for ac, el in etree.iterparse(fn):
        if el.tag == '{0}{1}'.format(xmlns, returntag):
            yield el
        elif el.tag in ns_ignore:
            formatting.clear_el(el)
520531
private String generateXml(String encrypt, String signature, String timestamp, String nonce) {
    String format =
        "<xml>\n"
            + "<Encrypt><![CDATA[%1$s]]></Encrypt>\n"
            + "<MsgSignature><![CDATA[%2$s]]></MsgSignature>\n"
            + "<TimeStamp>%3$s</TimeStamp>\n"
            + "<Nonce><![CDATA[%4$s]]></Nonce>\n"
            + "</xml>";
    return String.format(format, encrypt, signature, timestamp, nonce);
  }
901119
def parse_xml_string(self, xml, id_generator=None):
        """"""
        if id_generator is not None:
            warnings.warn(
                "Passing an id_generator directly is deprecated "
                "in favor of constructing the Runtime with the id_generator",
                DeprecationWarning,
                stacklevel=2,
            )

        id_generator = id_generator or self.id_generator
        if isinstance(xml, six.binary_type):
            io_type = BytesIO
        else:
            io_type = StringIO
        return self.parse_xml_file(io_type(xml), id_generator)
1218589
public final XmlStringBuilder getChildElementXML(XmlEnvironment enclosingXmlEnvironment) {
        XmlStringBuilder xml = new XmlStringBuilder();
        if (type == Type.error) {
            // Add the error sub-packet, if there is one.
            appendErrorIfExists(xml, enclosingXmlEnvironment);
        }
        else if (childElementName != null) {
            // Add the query section if there is one.
            IQChildElementXmlStringBuilder iqChildElement = getIQChildElementBuilder(new IQChildElementXmlStringBuilder(this));
            if (iqChildElement != null) {
                xml.append(iqChildElement);

                List<ExtensionElement> extensionsXml = getExtensions();
                if (iqChildElement.isEmptyElement) {
                    if (extensionsXml.isEmpty()) {
                         xml.closeEmptyElement();
                         return xml;
                    } else {
                        xml.rightAngleBracket();
                    }
                }
                xml.append(extensionsXml);
                xml.closeElement(iqChildElement.element);
            }
        }
        return xml;
    }
1288574
def fromXml(xml):
        
        walkthrough = XWalkthrough(name=xml.get('name', ''),
                                   version=xml.get('version'))
        
        for xslide in xml:
            walkthrough.addSlide(XWalkthroughSlide.fromXml(xslide))
        
        return walkthrough
96253
def fromxml(node):
        """"""
        if not isinstance(node,ElementTree._Element): #pylint: disable=protected-access
            node = parsexmlstring(node)
        if node.tag.lower() != 'meta':
            raise Exception("Expected meta tag but got '" + node.tag + "' instead")

        key = node.attrib['id']
        if node.text:
            value = node.text
        else:
            value = None
        operator = 'set'
        if 'operator' in node.attrib:
            operator= node.attrib['operator']
        if operator == 'set':
            cls = SetMetaField
        elif operator == 'unset':
            cls = UnsetMetaField
        elif operator == 'copy':
            cls = CopyMetaField
        elif operator == 'parameter':
            cls = ParameterMetaField
        return cls(key, value)
115186
def read_string(self, content):
        
        reader = source_reader.source_reader_t(
            self.__config,
            None,
            self.__decl_factory)
        decls = reader.read_string(content)
        self.__xml_generator_from_xml_file = reader.xml_generator_from_xml_file
        return decls
1177218
def c14n(xml):
    '''
    
    '''
    tree = etree.parse(StringIO(xml))
    output = StringIO()
    tree.write_c14n(output, exclusive=False, with_comments=True, compression=0)
    output.flush()
    c14nized = output.getvalue()
    output.close()
    return c14nized
1178181
def rec_introspect(node, path)
      xml = bus.introspect_data(@name, path)
      intfs, subnodes = IntrospectXMLParser.new(xml).parse
      subnodes.each do |nodename|
        subnode = node[nodename] = Node.new(nodename)
        subpath = if path == "/"
                    "/" + nodename
                  else
                    path + "/" + nodename
                  end
        rec_introspect(subnode, subpath)
      end
      return if intfs.empty?
      node.object = ProxyObjectFactory.new(xml, @bus, @name, path).build
    end