我有以下查询返回xml的一行中的所有内容,有没有办法让outpup以可读格式?如下面的示例。
SELECT XMLELEMENT("rss",
XMLATTRIBUTES('http://www.georss.org/georss' AS "xmlns:georss"),
XMLELEMENT("channel",
XMLAGG(XMLELEMENT("item",
XMLFOREST(title AS "title",
description AS "description",
point AS "georss:point"))))).EXTRACT('/*')
FROM (SELECT trim(s.sitedesc) AS title,
'Employee Count: ' || s.sitefte || '<br /> Bldg Gross SF: ' || s.bldgarea || '<br />' || CASE WHEN s.leasestat = '0' THEN 'Owned' WHEN s.leasestat = '1' THEN 'Leased, end date: ' || trim(l.edate) END || '<br /><a href="../scripts/fmiinfo.asp?file_code=_BLDGLIST&sitecode='||trim(s.sitecode)||'&forceDB=">'||'More Details'||'</a> <br />' AS description,
trim(s.latitude) || ' ' || trim(s.longitude) AS point
FROM ls s
LEFT OUTER JOIN c0 l ON l.sitecode = s.sitecode
WHERE s.sold <> 1
AND s.longitude != ' '
)
;
返回
<rss xmlns:georss="http://www.georss.org/georss"><channel><item><title>TITLE</title><description>DESCRIPTION<description><georss:point>LAT LON</georss:point></item> ... </channel></rss>
但为了让阅读更容易,输出更接近于此:
<rss xmlns:georss="http://www.georss.org/georss">
<channel>
<item>
<title>TITLE</title>
<description>DESCRIPTION</description>
<georss:point>LAT LON</georss:point>
</item>
...
</channel>
</rss>
答案 0 :(得分:0)
您可以使用一些shell脚本添加返回,如下所示:
#!/bin/sh
# Usage: ./addreturns.sh foobar.xml.
file=$1
cat $file | perl -pe 's|(<\/.*?>)|\1\n|g' | perl -pe 's|><|>\n<|g' > /tmp/newlines.xml; mv /tmp/newlines.xml $file