技术阿道 2019-09-18 15:30 采纳率: 22.2%
浏览 830
已结题

需要一个存有xml内容的字段中的数据,要怎么取?用sql

图片说明图片说明图片说明
红框圈起来的字段打开后是一段xml如第二张图,现在需要图中圈起来的数值,然后变成像第三张图这样的显示要怎么操作?求大神帮忙(详细)
百度了这个方法extractvalue,但是不会用,一直报错。(用sql语句实现,不是Java。要在plsql中查出这些数据,然后打印excel)

  • 写回答

4条回答

  • 到底有多少个小谢 2019-09-18 15:41
    关注

    下面方法是将xml字符串或blob转换为document对象。然后可以使用xpath在document中快速搜索到你需要的Element

    private Document setStrToDoc(String str){
            Document d = null;
            try{
                //SAXReader saxReader = new SAXReader();
                //d = saxReader.read(new ByteArrayInputStream(str.getBytes()));
                d = DocumentHelper.parseText(str);
            }catch (Exception e){
                System.out.println("String转Document错误!");
            }
            return d;
        }
    
        private Document setBlobToDoc(Blob blob){
            InputStream input = null;
            Document d = null;
            try{
                input = blob.getBinaryStream();
                SAXReader s=new SAXReader();
                d=s.read(input);
            }catch (Exception e){
    
            } finally {
                try {
                    //关闭输出流
                    if(input != null)
                        input.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return d;
        }
    
    评论

报告相同问题?

悬赏问题

  • ¥15 oracle集群安装出bug
  • ¥15 关于#python#的问题:自动化测试
  • ¥20 问题请教!vue项目关于Nginx配置nonce安全策略的问题
  • ¥15 教务系统账号被盗号如何追溯设备
  • ¥20 delta降尺度方法,未来数据怎么降尺度
  • ¥15 c# 使用NPOI快速将datatable数据导入excel中指定sheet,要求快速高效
  • ¥15 再不同版本的系统上,TCP传输速度不一致
  • ¥15 高德地图点聚合中Marker的位置无法实时更新
  • ¥15 DIFY API Endpoint 问题。
  • ¥20 sub地址DHCP问题