mayurk
mayurk

Reputation: 121

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>[email protected]</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 ?

Upvotes: 0

Views: 1806

Answers (1)

podiluska
podiluska

Reputation: 51494

If you know the sequence, you can use

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

Upvotes: 1

Related Questions