我正在使用com.sun.xml.txw2.output.IndentingXMLStreamWriter将数据写入xml文件:
OutputStream os = new FileOutputStream(pOutputFile); XMLOutputFactory xmlof = XMLOutputFactory.newInstance(); XMLStreamWriter xsw = new IndentingXMLStreamWriter(xmlof.createXMLStreamWriter(os)); marshaller.setProperty(Marshaller.JAXB_ENCODING, "UTF-8"); marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE); marshaller.setProperty(Marshaller.JAXB_NO_NAMESPACE_SCHEMA_LOCATION, translationXsdFile.getName()); marshaller.setSchema(schema); marshaller.marshal(xmlObject, xsw); xsw.close();
不幸的是,这导致引号“被编码为:
" (添加空格以在此处显示实体)
我希望将其编码为
在xml输出文件中" (添加空格以在此处显示实体)
而不重新解析/替换
的出现" (添加空格以在此处显示实体)