繁体   English   中英

如何使用 XQuery 替换

[英]How to replace using XQuery

我有一个 XML 文档,我需要替换

<json type="array">

为了

<m:telemoveis xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xmlns:m="http://www.projetoPei.com/Main"
 xsi:schemaLocation="http://www.projetoPei.com/Main Main.xsd">

我尝试了以下 FLOWER 表达式,但双引号显示为 &quote ; 。我究竟做错了什么? 另外如何在返回后使用 new-name 的值而不是 m ?

for $x in doc('FnacData.xml')/json
let $new-name :=" m:telemoveis xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;xmlns:m=&quot;https://www.projetoPei.com/Main&quot;xsi:schemaLocation=&quot;https://www.projetoPei.com/Main Main.xsd&quot;"
return 
    element m   {

        $x/*
    }

为什么要在变量中创建元素?

你可以像下面这样简单地使用:

for $x in doc('FnacData.xml')/json 
return 
<m:telemoveis xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:m="http://www.projetoPei.com/Main" xsi:schemaLocation="http://www.projetoPei.com/Main Main.xsd">
{$x}
</m:telemoveis>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM