0
votes

I have the following xquery expression for returning the title of a particular CD from an XML databases

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());
     }

The output I get from this query has the following format

[#text: 1999 Grammy Nominees] 

The question is that, how can improve the query to make the output get rid of that "#text:" thing, and produce only -1999 Grammy Nominees-. Thanks.

1
Just curious: What XML database is this? - Joe Wicentowski

1 Answers

1
votes

Does

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());
     }

do what you want?