Dump an XML document to a file or an URL.
434340
def saveFormatFileEnc(self, filename, encoding, format):
        
        ret = libxml2mod.xmlSaveFormatFileEnc(filename, self._o, encoding, format)
        return ret
834085
def dump(self, *args, **kwargs):
        """"""
        lxml.etree.dump(self._obj, *args, **kwargs)
444180
def output_xml(data, code, headers=None):
    """"""
    resp = make_response(dumps({'response' :data}), code)
    resp.headers.extend(headers or {})
    return resp
33437
public static DumpData toDumpData(Node node, PageContext pageContext, int maxlevel, DumpProperties props) {
	if (maxlevel <= 0) {
	    return DumpUtil.MAX_LEVEL_REACHED;
	}
	maxlevel--;
	// Document
	if (node instanceof Document) {
	    DumpTable table = new DumpTable("xml", "#cc9999", "#ffffff", "#000000");
	    table.setTitle("XML Document");
	    table.appendRow(1, new SimpleDumpData("XmlComment"), new SimpleDumpData(XMLUtil.getProperty(node, XMLUtil.XMLCOMMENT, null).toString()));
	    table.appendRow(1, new SimpleDumpData("XmlRoot"), DumpUtil.toDumpData(XMLUtil.getProperty(node, XMLUtil.XMLROOT, null), pageContext, maxlevel, props));
	    return table;

	}
	// Element
	if (node instanceof Element) {
	    DumpTable table = new DumpTable("xml", "#cc9999", "#ffffff", "#000000");
	    table.setTitle("XML Element");
	    table.appendRow(1, new SimpleDumpData("xmlName"), new SimpleDumpData(XMLUtil.getProperty(node, XMLUtil.XMLNAME, null).toString()));
	    table.appendRow(1, new SimpleDumpData("XmlNsPrefix"), new SimpleDumpData(XMLUtil.getProperty(node, XMLUtil.XMLNSPREFIX, null).toString()));
	    table.appendRow(1, new SimpleDumpData("XmlNsURI"), new SimpleDumpData(XMLUtil.getProperty(node, XMLUtil.XMLNSURI, null).toString()));
	    table.appendRow(1, new SimpleDumpData("XmlText"), DumpUtil.toDumpData(XMLUtil.getProperty(node, XMLUtil.XMLTEXT, null), pageContext, maxlevel, props));
	    table.appendRow(1, new SimpleDumpData("XmlComment"), new SimpleDumpData(XMLUtil.getProperty(node, XMLUtil.XMLCOMMENT, null).toString()));
	    table.appendRow(1, new SimpleDumpData("XmlAttributes"), DumpUtil.toDumpData(XMLUtil.getProperty(node, XMLUtil.XMLATTRIBUTES, null), pageContext, maxlevel, props));
	    table.appendRow(1, new SimpleDumpData("XmlChildren"), DumpUtil.toDumpData(XMLUtil.getProperty(node, XMLUtil.XMLCHILDREN, null), pageContext, maxlevel, props));
	    return table;

	}
	// Text
	if (node instanceof Text) {
	    DumpTable table = new DumpTable("xml", "#cc9999", "#ffffff", "#000000");
	    table.setTitle("XML Text");
	    Text txt = (Text) node;

	    table.appendRow(1, new SimpleDumpData("XmlText"), new SimpleDumpData(txt.getData()));
	    return table;

	}
	// Attr
	if (node instanceof Attr) {
	    DumpTable table = new DumpTable("xml", "#cc9999", "#ffffff", "#000000");
	    table.setTitle("XML Attr");
	    table.appendRow(1, new SimpleDumpData("xmlName"), new SimpleDumpData(XMLUtil.getProperty(node, XMLUtil.XMLNAME, null).toString()));
	    table.appendRow(1, new SimpleDumpData("XmlValue"), DumpUtil.toDumpData(((Attr) node).getValue(), pageContext, maxlevel, props));
	    table.appendRow(1, new SimpleDumpData("XmlType"), new SimpleDumpData(XMLUtil.getTypeAsString(node, true)));

	    return table;

	}
	// Node
	DumpTable table = new DumpTable("xml", "#cc9999", "#ffffff", "#000000");
	table.setTitle("XML Node (" + ListUtil.last(node.getClass().getName(), ".", true) + ")");
	table.appendRow(1, new SimpleDumpData("xmlName"), new SimpleDumpData(XMLUtil.getProperty(node, XMLUtil.XMLNAME, null).toString()));
	table.appendRow(1, new SimpleDumpData("XmlNsPrefix"), new SimpleDumpData(XMLUtil.getProperty(node, XMLUtil.XMLNSPREFIX, null).toString()));
	table.appendRow(1, new SimpleDumpData("XmlNsURI"), new SimpleDumpData(XMLUtil.getProperty(node, XMLUtil.XMLNSURI, null).toString()));
	table.appendRow(1, new SimpleDumpData("XmlText"), DumpUtil.toDumpData(XMLUtil.getProperty(node, XMLUtil.XMLTEXT, null), pageContext, maxlevel, props));
	table.appendRow(1, new SimpleDumpData("XmlComment"), new SimpleDumpData(XMLUtil.getProperty(node, XMLUtil.XMLCOMMENT, null).toString()));
	table.appendRow(1, new SimpleDumpData("XmlAttributes"), DumpUtil.toDumpData(XMLUtil.getProperty(node, XMLUtil.XMLATTRIBUTES, null), pageContext, maxlevel, props));
	table.appendRow(1, new SimpleDumpData("XmlChildren"), DumpUtil.toDumpData(XMLUtil.getProperty(node, XMLUtil.XMLCHILDREN, null), pageContext, maxlevel, props));

	table.appendRow(1, new SimpleDumpData("XmlType"), new SimpleDumpData(XMLUtil.getTypeAsString(node, true)));

	return table;
    }
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]
856518
static Document loadDocument(Resource xmlFile) throws SAXException, IOException {
	InputStream is = null;
	try {
	    return _loadDocument(is = IOUtil.toBufferedInputStream(xmlFile.getInputStream()));
	}
	finally {
	    IOUtil.closeEL(is);
	}
    }
1357792
def write_xml(xml, output_file=None):
        """"""
        gen_filename = "requirements-{:%Y%m%d%H%M%S}.xml".format(datetime.datetime.now())
        utils.write_xml(xml, output_loc=output_file, filename=gen_filename)
654879
def save_xml(self, doc, element):
        ''''''
        element.setAttributeNS(RTS_NS, RTS_NS_S + 'id', self.id)
        for c in self._config_data:
            new_element = doc.createElementNS(RTS_NS,
                                              RTS_NS_S + 'ConfigurationData')
            c.save_xml(doc, new_element)
            element.appendChild(new_element)
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)
674802
def save_xml(self, doc, element):
        ''''''
        element.setAttributeNS(RTS_NS, RTS_NS_S + 'groupID', self.group_id)
        for m in self.members:
            new_element = doc.createElementNS(RTS_NS, RTS_NS_S + 'Members')
            m.save_xml(doc, new_element)
            element.appendChild(new_element)
408149
def saveXml(self, xml):
        
        # save grouping
        xtree = ElementTree.SubElement(xml, 'tree')
        self.uiRecordTREE.saveXml(xtree)
        
        # save the query
        query = self.query()
        if query:
            query.toXml(ElementTree.SubElement(xml, 'query'))
486827
public function dump()
    {
        // Create a new XML document
        $document = new \DOMDocument('1.0', 'utf-8');
        $document->preserveWhiteSpace = false;
        $document->formatOutput = true;
        $document->loadXML($this->xml->asXML());

        return $document->saveXML();
    }
399673
def _write_xml(xmlfile, srcs):
        
        root = ElementTree.Element('source_library')
        root.set('title', 'source_library')

        for src in srcs:
            src.write_xml(root)

        output_file = open(xmlfile, 'w')
        output_file.write(utils.prettify_xml(root))
344791
def to_file(f)
      result = client.query(last_statement, :stream => true, :cache_rows => false, :as => :array)
      escaped_fields = result.fields.map { |k| k.to_xs }

      f.write %{<?xml version="1.0" encoding="utf-8" ?>}
      f.write %{<resultset statement="#{config.execute.to_xs}" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">}
      result.each do |ary|
        next if ary.nil?
        f.write %{<row>}
        ary.each_with_index do |v, i|
          f.write %{<field name="#{escaped_fields[i]}"#{' xsi:nil="true"' if v.nil?}>#{v.to_s.to_xs}</field>}
        end
        f.write %{</row>}
      end
      f.write %{</resultset>}
      nil
    end
960956
private void saveSummaryXml(SampleNode root) {

        root.sortTree();
        Document doc = DocumentHelper.createDocument();
        Element rootElem = doc.addElement("root");
        root.appendToXml(rootElem);
        OutputFormat outformat = OutputFormat.createPrettyPrint();
        ByteArrayOutputStream buffer = new ByteArrayOutputStream();
        outformat.setEncoding("UTF-8");
        try {
            XMLWriter writer = new XMLWriter(buffer, outformat);
            writer.write(doc);
            writer.flush();
            try (FileOutputStream fos = new FileOutputStream(m_summaryFilename)) {
                fos.write(buffer.toByteArray());
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
807080
def save_xml(self, doc, element):
        ''''''
        element.setAttributeNS(XSI_NS, XSI_NS_S + 'type', 'rtsExt:execution_context_ext')
        element.setAttributeNS(RTS_NS, RTS_NS_S + 'id', self.id)
        element.setAttributeNS(RTS_NS, RTS_NS_S + 'kind', self.kind)
        element.setAttributeNS(RTS_NS, RTS_NS_S + 'rate', str(self.rate))
        for p in self.participants:
            new_element = doc.createElementNS(RTS_NS,
                                              RTS_NS_S + 'Participants')
            p.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)
770514
def object2xml(self, data):
        
        """
        if not self.__options['encoding']:
            self.set_options(encoding=self.__encoding)

        if self.__options['header_declare']:
            self.__tree.append(self.build_xml_header())

        root = self.__options['root']
        if not root:
            assert (isinstance(data, utils.DictTypes) and len(data) == 1), \
                'if root not specified, the data that dict object and length must be one required.'
            root, data = data.items()[0]

        self.build_tree(data, root)
        xml = unicode(''.join(self.__tree).strip())

        if self.__options['encoding'] != self.__encoding:
            xml = xml.encode(self.__options['encoding'], errors=self.__options['errors'])
        return xml