关于dom4j处理转义字符
我的xml里有转义字符,如"、>等。
我用dom4j对xml进行处理,然后重新写回。
public static void execute(/*一些参数*/) throws Exception {
filepath = "D:\\form.xml";
SAXReader reader = new SAXReader();
Document doc = reader.read(new File(filepath));
//......一些处理
XMLWriter xmlWriter = new XMLWriter(new FileOutputStream(filepath));
xmlWriter.write(doc);
xmlWriter.close();
}OutputFormat format = OutputFormat.createPrettyPrint();
format.setEncoding("utf-8");
XMLWriter writer = new XMLWriter(new OutputStreamWriter(new FileOutputStream(filename), "utf-8"), format);
writer.write(document);
writer.close();
<script>
<![CDATA[
function matchwo(a,b)
{
if (a < b && a < 0) then
{
return 1;
}
else
{
return 0;
}
}
]]>
</script>