Question

Deleting elements in an XML file

  • 17 May 2019
  • 1 reply
  • 26 views

I have an XML file (see example attachment) from which I want to delete all Notification elements when the Notification type is 'Change of Circumstances'. So in this case I'd start with 3 Notification elements (New Claim, Change of Circumstances and Claim Termination) and once I've deleted the 'Change of Circumstances' Notification I'd just be left with 2 Notification elements (New Claim and Claim Termination).

I'd found this article (https://knowledge.safe.com/questions/77687/deleting-elements-in-xml-file.html) which seems to be what I'm after but I'm struggling to replicate it with my file.

I've been using Text File Reader with parameter 'Read Whole File at Once' set to 'Yes' and the XMLUpdater with Delete XML Path (though I'm struggling what syntax I need in the XML Path).

For info. I'm using Workbench 2018.1.2

Thanks in advance.


1 reply

Userlevel 2
Badge +17

This XPath expression might be what you want.

//Notification[@type="Change of Circumstances"]

See here to learn more about XPath: XPath Tutorial

Reply