您的位置:首页 > 其它

读取Clob字段的xml并解析此xml

2008-10-24 15:31 771 查看
public String getRs_Value()(

............//数据库联接,查询,得到结果集

String stuff="":

if(rs.next()){
Clob clob = rs.getClob(1);
if(clob!=null){
Reader is = clob.getCharacterStream();
BufferedReader br = new BufferedReader(is);
String s = br.readLine();
while(s!=null){
stuff += s;
s=br.readLine();
}

}
}

}

public String getXmlV(String stuff){
try {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = null;
builder = factory.newDocumentBuilder();
Document doc = null;
doc = builder.parse( new InputSource( new StringReader( stuff ) ) );
doc.normalize();
System.out.println(" echo ");
NodeList nodeList = doc.getElementsByTagName("DATA");
System.out.println(nodeList.getLength());
for (int i = 0; i < nodeList.getLength(); i++) {
String value = doc.getElementsByTagName("VALUE").item(i).
getFirstChild().getNodeValue();
System.out.println(" value "+value);
if(key.indexOf("DOCUMENT_ID")>=0){
no = value;
break;

}
}

System.out.println("处罚或许可的文书号 : "+no);

doc.normalize();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

return no;

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: