Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
SQL将XML中的符号替换为';和';_Xml_Replace_Xquery - Fatal编程技术网

SQL将XML中的符号替换为';和';

SQL将XML中的符号替换为';和';,xml,replace,xquery,Xml,Replace,Xquery,我想替换符号,显示为& XML的结构是 <xs:simpleType name="ImportedData_Space_TypeType"> <xs:restriction base="xs:string"> <xs:enumeration value="SupportSpace" /> <xs:enumeration value="Teach&amp;ResSpace" /> <xs:enumeration val

我想替换符号,显示为
&

XML的结构是

<xs:simpleType name="ImportedData_Space_TypeType">
<xs:restriction base="xs:string">
  <xs:enumeration value="SupportSpace" />
  <xs:enumeration value="Teach&amp;ResSpace" />
  <xs:enumeration value="Teach&amp;ResSpecialistSpace" />
 </xs:restriction>

我试图返回一个视图,需要返回
&作为


我看过xquery,但不确定这是否是最好的方法?

只需使用replace函数,例如

declare variable $test := <ImportedData_Space_TypeType>Teach&amp;ResSpace</ImportedData_Space_TypeType>;
<ImportedData_Space_TypeType>{replace($test, "&amp;", "and")}</ImportedData_Space_TypeType>

使用XSLT做这件事要容易得多,XSLT是一个标识模板,由一个匹配
ImportedData\u Space\u TypeType/text()的模板覆盖,在覆盖模板中只需:
copy $c := $test
modify replace value of node $c with replace($c, "&amp;", "and")
return $c