0

我有以下 xquery 表达式用于从 XML 数据库返回特定 CD 的标题

String queryString =
                "declare variable $docName as xs:string external;"  + sep +    
                "for $cd in doc($docName)/*/"+"CD[1]"+"/TITLE"+        
                " return $cd/text()";
     XQPreparedExpression expr = conn.prepareExpression(queryString);
     expr.bindString(new QName("docName"), filename,
              conn.createAtomicType(XQItemType.XQBASETYPE_STRING));
     XQResultSequence rs = expr.executeQuery();
     while(rs.next()){
         System.out.println(rs.getObject());
     }

我从此查询获得的输出具有以下格式

[#text: 1999 Grammy Nominees] 

问题是,如何改进查询以使输出摆脱那个“#text:”的东西,并且只产生 -1999 格莱美提名 -。谢谢。

4

1 回答 1

1

String queryString =
                "declare variable $docName as xs:string external;"  + sep +    
                "for $cd in doc($docName)/*/"+"CD[1]"+"/TITLE"+        
                " return string($cd)";

XQResultSequence rs = expr.executeQuery();
     while(rs.next()){
         System.out.println(rs.getAtomicValue());
     }

做你想做的事?

于 2012-06-24T11:53:34.417 回答