I have a XML file that looks something like this, and I only want to replace the last occurrence of /Shipment with /ShipHdr /ShipmentX:

```
<ShipmentX>
  <ShipHdr>
   <RefID>REF01</RefID>
   <HeaderReferenceNumber>1234565</HeaderReferenceNumber>
   <Shipment>
     <RefCode>GHIJK</RefCode>
     <ShipmentStatusCode>FG</ShipmentStatusCode>
   </Shipment>
   <Summary>
     <TotalWeight>10</TotalWeight>
   </Summary>
</Shipment>

```

Output:

```
<ShipmentX>
  <ShipHdr>
   <RefID>REF01</RefID>
   <HeaderReferenceNumber>1234565</HeaderReferenceNumber>
   <Shipment>
     <RefCode>GHIJK</RefCode>
     <ShipmentStatusCode>FG</ShipmentStatusCode>
   </Shipment>
   <Summary>
     <TotalWeight>10</TotalWeight>
   </Summary>
  </ShipHdr>
</ShipmentX>

```

Any advice on how I can do this using perl or sed in a bash script?

Thanks!