我有以下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格莱美提名 - 。 感谢。
答案 0 :(得分: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());
}
做你想做的事吗?