关于加载含有中文内容的UTF-8编码的XML文件
Java code:
response.setContentType("text/xml; charset=UTF-8");
String news = URLDecoder.decode(request.getParameter("news"),"UTF-8");
String path=request.getRealPath("/");
path=path+"config\\gridnews.xml";
path.replace("\\","\\\\");
System.out.println(path);
File list = new File(path);
list.createNewFile();
FileWriter fw =new FileWriter(list);
fw.write("<?xml version="+'"'+"1.0"+'"'+" encoding="+'"'+"UTF-8"+'"'+"?>");
fw.write("<all_info>");
fw.write("<news>"+news+"</news>");
fw.write("</all_info>");
fw.close();
out.print("成功");
out.close();
输出了上面的XML文件,然后用下面的代码读取,但是内容如果是或中文就读取不到信息.
Java code:
DocumentBuilderFactory dbf=DocumentBuilderFactory.newInstance();
DocumentBuilder db=null;
db = dbf.newDocumentBuilder();
org.w3c.dom.Document doc = null;
String path=request.getRealPath("
相关问答:
DataSet导出xml 批处理(循环)得怎么处理
XML文件
<A>
<B>
<C>
</C>
&nb ......
已知文件1.xml和数据文件db.xml,如何用java编写程序,得出2.xml文件?
1.已知xml文件 1.xml结构如下:
<cs>
<cs name="cs1" details="This is cs1" country="China&q ......
<?xml version="1.0"?>
<root>
<status>433</status>
<msg>这个是汉字</msg>
<serialno>123</serialno>
</root>
如何用ASP读取 status值 ......
<?xml version="1.0" encoding="utf-8" ?>
- <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical&q ......
我在编写一个wince5.0的程序,想实现把PDA上的一个LIST <STRING>类型的数据序列化为XML,然后在PC上的一个webservice拿到这个XML,转化为Dataset,更新PC上的数据库,我想问怎么把XML传给webservice的呢?
......