[英]Replace at once all the elements of an xml document with Xquery/XUpdate
給定以下 xml 文件:
<?xml-stylesheet type="text/xsl" href="cars.xsl"?>
<garagexmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="cars.xsd"><!--Enlazar su XSD-->
<car>
<color>red</color>
<power>120</power>
<seats>5</seats>
<price>33500</price>
</car>
<car>
<color>white</color>
<power>120</power>
<seats>5</seats>
<price>23500</price>
</car>
<car>
<color>blue</color>
<power>200</power>
<seats>5</seats>
<price>45500</price>
</car>
</garage>
我想替換所有“顏色”元素,使其內容為“白色”。 這是我的嘗試:
update replace /garage/car/color[.="*"]
with "white"
謝謝
這比預期的要容易:
update replace /garage/car/color
with <color>white</color>
PS.Stackoverflow 論壇上仍然沒有“XUpdate”標簽。 如果有人添加它會很好。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.