读取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;
}
............//数据库联接,查询,得到结果集
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;
}
相关文章推荐
- 带参数的可执行jar包程序实现从指定位置读取xml并解析指定字段
- jquery-ajax请求action读取oracle数据库clob字段xml数据格式化显示(struts2)
- Oracle中通过游标执行带参数的存储过程实现解析CLOB字段内的xml字符串:
- Oracle中通过:触发器,存储过程,Function调用实现解析Clob字段类型中存储的xml字符串
- Oracle中通过Function,存储过程,触发器,调用实现解析Clob字段中存在的xml字符串
- Oracle存储过程中使用游标来批量解析CLOB字段里面的xml字符串:
- XStream解析xml为bean时,避免xml出现多余字段报错
- 最简单的读取CLOB字段的代码
- rapidxml读取包含中文路径的xml解析错误的解决方法
- boost::property_tree读取解析.xml文件
- 在SQL2005里直接读取XML并解析其内容
- Java 存储和读取 oracle CLOB 类型字段
- 读取与解析XML数据(SAX、DOM、PULL)
- Java眼中的XML--文件读取--2 应用SAX方式解析XML
- 使用java读取/解析XML数据
- JavaScript 解析读取XML文档 实例代码
- 读取CLOB字段的意思。
- rapidxml读取包含中文路径的xml解析错误的解决方法
- XML中定位字段修改、读取[原创]
- Java眼中的XML--文件读取--2 应用SAX方式解析XML