success: function(data){ //data.xml check for IE var xmlstr = data.xml ? data.xml : (new XMLSerializer()).serializeToString(data); alert(xmlstr); }
//then convert it back to a string //for IE if (window.ActiveXObject) { var str = t.xml; alert(str); } // code for Mozilla, Firefox, Opera, etc. else { var str = (new XMLSerializer()).serializeToString(t); alert(str); }
var xmlString = (new XMLSerializer()).serializeToString(xml);
new XMLSerializer().serializeToString(xmlObject.documentElement);
var sOuterHTML = new XMLSerializer().serializeToString(oElement);
var inputAttr = this.outerHTML || new XMLSerializer().serializeToString(this);
new XMLSerializer().serializeToString(document.doctype);
//get svg element. var svg = document.getElementById("svg"); //get svg source. var serializer = new XMLSerializer(); var source = serializer.serializeToString(svg); //add name spaces. if(!source.match(/^<svg[^>]+xmlns="http\:\/\/www\.w3\.org\/2000\/svg"/)){ source = source.replace(/^<svg/, '<svg xmlns="http://www.w3.org/2000/svg"'); } if(!source.match(/^<svg[^>]+"http\:\/\/www\.w3\.org\/1999\/xlink"/)){ source = source.replace(/^<svg/, '<svg xmlns:xlink="http://www.w3.org/1999/xlink"'); } //add xml declaration source = '<?xml version="1.0" standalone="no"?>\r\n' + source; //convert svg source to URI data scheme. var url = "data:image/svg+xml;charset=utf-8,"+encodeURIComponent(source); //set url value to a element's href attribute. document.getElementById("link").href = url; //you can download svg file by right click menu.
trace=new org.apache.xml.serialize.XMLSerializer(System.out,null); parser.setContentHandler(trace); parser.setLexicalHandler(trace);
private static XMLSerializer getXMLSerializer(final OutputStream os, final String[] cdataElements) throws InstantiationException, IllegalAccessException, ClassNotFoundException { // configure an OutputFormat to handle CDATA final OutputFormat of = new OutputFormat(); // specify which of your elements you want to be handled as CDATA. // The use of the '^' between the namespaceURI and the localname // seems to be an implementation detail of the xerces code. // When processing xml that doesn't use namespaces, simply omit the // namespace prefix as shown in the third CDataElement below. of.setCDataElements(cdataElements); // set any other options you'd like of.setPreserveSpace(true); of.setIndenting(true); // create the serializer final XMLSerializer serializer = new XMLSerializer(of); serializer.setOutputByteStream(os); return serializer; }
var document = iframeObject.contentDocument var serializer = new XMLSerializer(); var content = serializer.serializeToString(document);
new XMLSerializer().serializeToString(mi); // "<input type="text" value="default">"
var serializer = new XMLSerializer(); var xmlString = serializer.serializeToString(xmlDoc);
var s = new XMLSerializer().serializeToString(document.getElementById("svg"))
import org.apache.xml.serialize.OutputFormat; import org.apache.xml.serialize.XMLSerializer; ... XMLSerializer serializer = new XMLSerializer(); serializer.setOutputCharStream(new java.io.FileWriter("output.xml")); OutputFormat format = new OutputFormat(); format.setStandalone(true); serializer.setOutputFormat(format); serializer.serialize(dom);
String xml = "<hello><test>1.2</test><test2>123</test2></hello>"; XMLSerializer xmlSerializer = new XMLSerializer(); JSON json = xmlSerializer.read( xml );
String xml = "<hello><test>1.2</test><test2>123</test2></hello>"; XMLSerializer xmlSerializer = new XMLSerializer(); JSON json = xmlSerializer.read("<x>" + xml + "</x>");
public OutputStream write() { XMLConf xmlConfig = createXMLConfiguration(); OutputStream out = new ByteArrayOutputStream(); try { XMLSerializer serializer = new XMLSerializer(out, createOutputFormat()); serializer.serialize(xmlConfig.getDocument()); out.close(); } catch (IOException e) { throw new RuntimeException(e); } return out; }
public void write(String filename) { if (!filename.endsWith(".xml")) filename += ".xml"; log.info("write vrp: " + filename); XMLConf xmlConfig = createXMLConfiguration(); try { xmlConfig.setFileName(filename); Writer out = new FileWriter(filename); XMLSerializer serializer = new XMLSerializer(out, createOutputFormat()); serializer.serialize(xmlConfig.getDocument()); out.close(); } catch (IOException e) { throw new RuntimeException(e); } }
public static void validate( Document doc, String schemaLocationPropertyValue, EntityResolver resolver) throws IOException, SAXException { OutputFormat format = new OutputFormat(doc, null, true); StringWriter writer = new StringWriter(1000); XMLSerializer serial = new XMLSerializer(writer, format); serial.asDOMSerializer(); serial.serialize(doc); String docString = writer.toString(); validate(docString, schemaLocationPropertyValue, resolver); }