67,547
社区成员
发帖
与我相关
我的任务
分享
String xmlStr="xxxx"//一串带有中文的xml字符串
SAXBuilder builder = new SAXBuilder(false);
Document doc = null;
BufferedReader br=null;
InputStream is=null;
try {
is=new ByteArrayInputStream(xmlStr.getBytes());
br=new BufferedReader(new InputStreamReader(is,"UTF-8"));
doc = builder.build(br);
} catch (Exception e) {
log.error("xml read error!!!", e);
return null;
}
Element root = doc.getRootElement();
<?xml version="1.0" encoding="UTF-8" ?>
<root>
<Type>200300</Type>
<DATE>2011-08-05 01:41:13</DATE>
<Content>
<PRID>2302</PRID>
<PRCrtName>潘晨</PRCrtName>
<PRCrtBank>交通银行湖北省分行</PRCrtBank>
<PRCrtDept>综合科</PRCrtDept>
<PRCrtOffice />
<PRRetName>潘晨</PRRetName>
<PRRetBank>交通银行湖北省分行</PRRetBank>
<PRRetDept />
<PRRetOffice />
<PRRetMobile>18602753177</PRRetMobile>
<PRTitle>p[</PRTitle>
<PRDesc>网点号:交易码:报错代码:报错信息:期望结果:交易柜员号:</PRDesc>
<PRHappenTime>2011/08/05 13:37:00</PRHappenTime>
<PRCategoryID>2</PRCategoryID>
<PRCategory>分类1</PRCategory>
<PRType>分类11</PRType>
<PRItem>分类112</PRItem>
<PRImpact>C</PRImpact>
<DealTime>2011-08-05 01:41:13</DealTime>
<DealStatus>1</DealStatus>
</Content>
</root>
<?xml version="1.0" encoding="UTF-8"?><root><Type>200300</Type><DATE>2011-08-05 01:41:13</DATE><Content><PRID>2302</PRID><PRCrtName>潘晨</PRCrtName><PRCrtBank>交通银行湖北省分行</PRCrtBank><PRCrtDept>综合科</PRCrtDept><PRCrtOffice></PRCrtOffice><PRRetName>潘晨</PRRetName><PRRetBank>交通银行湖北省分行</PRRetBank><PRRetDept></PRRetDept><PRRetOffice></PRRetOffice><PRRetMobile>18602753177</PRRetMobile><PRTitle>p[</PRTitle><PRDesc>网点号:
交易码:
报错代码:
报错信息:
期望结果:
交易柜员号:
</PRDesc><PRHappenTime>2011/08/05 13:37:00</PRHappenTime><PRCategoryID>2</PRCategoryID><PRCategory>分类1</PRCategory><PRType>分类11</PRType><PRItem>分类112</PRItem><PRImpact>C</PRImpact><DealTime>2011-08-05 01:41:13</DealTime><DealStatus>1</DealStatus></Content></root>