I dom4j for xml processing, and then re- write back .
public static void execute(/*一些参数*/) throws Exception {xml file
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();
}
get inside " into a double quotation mark , > unchanged.
I want him to have the same , " or ", do not become double quotes.
Online, thank you.
------ Solution ---------------------------------------- ----
saxRead.setEncoding ("UTF-8"); specify the format you use , GB2312
------ Solution -------------- ------------------------------
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();
------ Solution ---- ----------------------------------------
try cdata, Portal: http://www.w3school.com.cn/xml/xml_cdata.asp
<script>
<![CDATA[
function matchwo(a,b)
{
if (a < b && a < 0) then
{
return 1;
}
else
{
return 0;
}
}
]]>
</script>
------ Solution ------------------------------------- -------
that you put it up
------ Solution ------ --------------------------------------
/ / add xml file transcoding another method
OutputFormat format = OutputFormat.createPrettyPrint ();
format.setEncoding ("UTF-8");
XMLWriter writer = new XMLWriter (new FileOutputStream ("src / book.xml"), format);
writer.write (document);
writer.close ();
}
original source : http://blog.csdn.net/tianyazaiheruan/article/details/8065722
------ For reference only -------------------------------------- -
This method does not work , " into a double quotes.
------ For reference only -------------------------------------- -
This method does not work , " into a double quotes.
------ For reference only -------------------------------------- -
xml is generated by other software xml, can not change the format .
------ For reference only -------------------------------------- -
xml is generated by other software xml, can not change the format .
------ For reference only -------------------------------------- -
I try to read into the first string converted to xml document, but a problem with the byte stream will be garbled , with a character stream " or become double quotes.
------ For reference only -------------------------------------- -
who can help me ah
------ For reference only ---------------------------- -----------
I also encountered the same problem , the landlord solved?
没有评论:
发表评论