2012-03-01 59 views
0

我有一個PostgreSQL函數,它返回我一個XML,其中我的表的所有信息。PostgreSQL:獲得函數的結果

這是我的函數:

/* get all cat names */ 
create function cat_names() returns xml as $$ 
select to_xml('select name FROM cat_Infos;'); 
$$ language sql; 

得到的結果我不如下因素:

ResultSet rs = sql.executeQuery("select cat_names()"); 
while (rs.next()) { 
    // This is where I actually thought that I could pass the XML I get, to my DOMParser. 
    // I thought about something like this : 
    DOMParser dom = new DOMParser(); 
    dom.setImputString(//Xml I get from the resultset) 
} 

的問題是,我竟然不知道如何從ResultSet中的XML。

回答

0

您應該能夠使用

String xml = rs.getString(1) 

得到XML字符串