Save this data port into an xml.dom.Element object.
549729
def save_xml(self, doc, element):
        ''''''
        element.setAttributeNS(XSI_NS, XSI_NS_S + 'type', 'rtsExt:dataport_connector_ext')
        element.setAttributeNS(RTS_NS, RTS_NS_S + 'connectorId',
                               self.connector_id)
        element.setAttributeNS(RTS_NS, RTS_NS_S + 'name', self.name)
        element.setAttributeNS(RTS_NS, RTS_NS_S + 'dataType', self.data_type)
        element.setAttributeNS(RTS_NS, RTS_NS_S + 'interfaceType',
                               self.interface_type)
        element.setAttributeNS(RTS_NS, RTS_NS_S + 'dataflowType',
                               self.data_flow_type)
        if self.subscription_type:
            element.setAttributeNS(RTS_NS, RTS_NS_S + 'subscriptionType',
                                   self.subscription_type)
        if self.push_interval != 0.0:
            element.setAttributeNS(RTS_NS, RTS_NS_S + 'pushInterval',
                                   str(self.push_interval))
        if self.comment:
            element.setAttributeNS(RTS_EXT_NS, RTS_EXT_NS_S + 'comment',
                                   self.comment)
        if self.visible != True:
            element.setAttributeNS(RTS_EXT_NS, RTS_EXT_NS_S + 'visible',
                                   str(self.visible).lower())
        new_element = doc.createElementNS(RTS_NS, RTS_NS_S + 'sourceDataPort')
        self.source_data_port.save_xml(doc, new_element)
        element.appendChild(new_element)
        new_element = doc.createElementNS(RTS_NS, RTS_NS_S + 'targetDataPort')
        self.target_data_port.save_xml(doc, new_element)
        element.appendChild(new_element)
        for p in self.properties:
            new_prop_element = doc.createElementNS(RTS_EXT_NS,
                                                   RTS_EXT_NS_S + 'Properties')
            properties_to_xml(new_prop_element, p, self.properties[p])
            element.appendChild(new_prop_element)
98258
def saveXml(self, xml):
        
        xscript = ElementTree.SubElement(xml, 'script')
        xscript.text = escape(self._edit.toPlainText())
349615
def update_xml_element(self):
        

        if not hasattr(self, 'xml_element'):
            self.xml_element = etree.Element(self.name, nsmap=NSMAP)

        if hasattr(self, 'idref'):
            self.xml_element.set('idref', self.idref)

        return self.xml_element
590025
def XML(uri, tc, ps, **keywords):
    '''
    '''
    source = urllib.urlopen(uri, **keywords)
    enc = source.info().getencoding()
    if enc in ['7bit', '8bit', 'binary']:
        data = source
    else:
        data = StringIO.StringIO()
        mimetools.decode(source, data, enc)
        data.seek(0)
    dom = ps.readerclass().fromStream(data)
    return _child_elements(dom)[0]
1016935
public static void serialize(Element element, OutputStream os) {
        Source source = new DOMSource(element);
        serialize(source, os);
    }
788118
def save(self, data, xparent=None):
        
        if xparent is not None:
            elem = ElementTree.SubElement(xparent, 'list')
        else:
            elem = ElementTree.Element('list')

        for item in data:
            XmlDataIO.toXml(item, elem)

        return elem
640072
def save_xml(self, doc, element):
        ''''''
        super(Preceding, self).save_xml(doc, element)
        pre_element = doc.createElementNS(RTS_NS, RTS_NS_S + 'Preceding')
        if self.timeout:
            pre_element.setAttributeNS(RTS_NS, RTS_NS_S + 'timeout',
                    str(self.timeout))
        if self.sending_timing:
            pre_element.setAttributeNS(RTS_NS, RTS_NS_S + 'sendingTiming',
                                   self.sending_timing)
        for pc in self._preceding_components:
            new_element = doc.createElementNS(RTS_NS,
                                              RTS_NS_S + 'PrecedingComponents')
            pc.save_xml(doc, new_element)
            pre_element.appendChild(new_element)
        element.appendChild(pre_element)
153253
def _debug_dump_dom(el):
    """"""
    import xml.dom.minidom
    s = [el.nodeName]
    att_container = el.attributes
    for i in range(att_container.length):
        attr = att_container.item(i)
        s.append('  @{a}="{v}"'.format(a=attr.name, v=attr.value))
    for c in el.childNodes:
        if c.nodeType == xml.dom.minidom.Node.TEXT_NODE:
            s.append('  {a} type="TEXT" data="{d}"'.format(a=c.nodeName, d=c.data))
        else:
            s.append('  {a} child'.format(a=c.nodeName))
    return '\n'.join(s)
304693
def serialise(self, element: Element) -> str:
        

        return json.dumps(self.serialise_element(element))
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)
459079
def createElement(self, token):
        """"""
        name = token["name"]
        namespace = token.get("namespace", self.defaultNamespace)
        element = self.elementClass(name, namespace)
        element.attributes = token["data"]
        return element
1157885
def element_to_string(element, include_declaration=True, encoding=DEFAULT_ENCODING, method='xml'):
    

    if isinstance(element, ElementTree):
        element = element.getroot()
    elif not isinstance(element, ElementType):
        element = get_element(element)

    if element is None:
        return u''

    element_as_string = tostring(element, encoding, method).decode(encoding=encoding)
    if include_declaration:
        return element_as_string
    else:
        return strip_xml_declaration(element_as_string)
647201
def saveXml( self, xparent, item ):
        
        key = nativestring(unwrapVariant(item.data(0, Qt.UserRole)))
        
        if ( key == 'separator' ):
            ElementTree.SubElement(xparent, 'separator')
        elif ( key == 'menu' ):
            elem = ElementTree.SubElement(xparent, 'menu')
            elem.set('title', nativestring(item.text(0)))
            
            for c in range(item.childCount()):
                self.saveXml(elem, item.child(c))
        else:
            elem = ElementTree.SubElement(xparent, 'action')
            elem.set('name', key)
700795
def saveXml(self, xml):
        
        lvls = []
        for logger, level in self.loggerLevels().items():
            lvls.append('{0}:{1}'.format(logger, level))
        
        xlevels = ElementTree.SubElement(xml, 'levels')
        xlevels.text = ','.join(map(str, self.activeLevels()))
        
        xloggerlevels = ElementTree.SubElement(xml, 'logger_levels')
        xloggerlevels.text = ','.join(lvls)
        
        xml.set('filter', wrapVariant(self.uiFilterTXT.text()))
        
        xtree = ElementTree.SubElement(xml, 'tree')
        self.uiRecordTREE.saveXml(xtree)
311552
def save_xml(self, doc, element):
        ''''''
        element.setAttributeNS(RTS_NS, RTS_NS_S + 'componentId',
                               self.component_id)
        element.setAttributeNS(RTS_NS, RTS_NS_S + 'instanceName',
                               self.instance_name)
        for p in self.properties:
            new_prop_element = doc.createElementNS(RTS_EXT_NS,
                                                   RTS_EXT_NS_S + 'Properties')
            properties_to_xml(new_prop_element, p, self.properties[p])
            element.appendChild(new_prop_element)
353155
public static void serialize(Element element, Writer w) {
        Source source = new DOMSource(element);
        serialize(source, w);
    }
649980
def port(self, value):
        

        self._port = value
        # If port is None we remove the element and don't write it to XML
        if value is None:
            try:
                del self._connectionXML.attrib['port']
            except KeyError:
                pass
        else:
            self._connectionXML.set('port', value)