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;
}
本文介绍了一种从数据库CLOB类型中读取并解析XML数据的方法。具体步骤包括使用Java进行数据库连接、读取CLOB字段内容,并通过DOM解析器获取特定节点的值。

被折叠的 条评论
为什么被折叠?



