xmlroot() 是一个系统函数,用于修改 XML 值根节点的属性。
xmlroot() 在 PostgreSQL 8.3 中添加。
用法
xmlroot (xml,VERSION{text|NO VALUE} [,STANDALONE{YES|NO|NO VALUE} ] ) →xml
xmlroot() 修改根元素 <?xml ... ?> 的 version 和可选的 standalone 属性。
变更历史
- PostgreSQL 8.3
- 添加(提交 8c1de5fb)
示例
xmlroot() 的基本用法示例
postgres=# SELECT xmlroot(xmlparse(document '<?xml version="1.0"?><content>abc</content>'),
version '0.9', standalone yes);
xmlroot
--------------------------------------------------------------
<?xml version="0.9" standalone="yes"?><content>abc</content>
(1 row)
无法仅设置 STANDALONE 选项
postgres=# SELECT xmlroot(xmlparse(document 'abc'),
standalone yes);
ERROR: syntax error at or near "standalone"
LINE 2: standalone yes);
^
参考资料
- PostgreSQL 文档: Xmlroot
