简体   繁体   中英

delete all child nodes after nth child node from xml in sql

I have the following XML structure :

<Config>
  <DeviceFeatures>
    <IMEI>7844454564</IMEI>
    <PhoneNo>12354</PhoneNo>
    <ICCIDNo>455554</ICCIDNo>
    <IMSINo>87451</IMSINo>
    <UniqueDeviceId>360</UniqueDeviceId>
    <UserId>511154565@showcase.n</UserId>
    <Password>test123</Password>
    <Proxy>129.192.174.126</Proxy>
    <Proxy_Port>5060</Proxy_Port>
  </DeviceFeatures>
</Config>

And I want to delete all child nodes that come after the node <UniqueDeviceId></UniqueDeviceId> .

I want to delete the specific (UserId,Password,Proxy,Proxy_Port) nodes.

I've already tried the following :

DeviceFeatures.modify ('delete (/Config/DeviceFeatures/*)')

But it will delete all child nodes.

I've tried some other solutions and it seems not working at all, and I don't want to write multiple update statements to delete single nodes.

Does anybody know a possible solution for this scenario ?

如果知道顺序,可以使用

 DeviceFeatures.modify ('delete /Config/DeviceFeatures/*[position()>=6]')

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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