Fellow Forum Members,
I learned a NotePad++ regular expression is not the right tool for what I need to do. Therefore, I am hoping someone in this forum can tell me if an Excel VBA is the correct tool. I am using Excel for Office 365 v16. An "XML Block Relocator" is the best name I can think of for the VBA I need. Its purpose is to move within the same file an XML block to another location downstream in the XML code. Below is a summary of how I need the VBA to perform:
I need the VBA to fetch from an XML file list located in "Column A". The "Column A" list contains 300 XML files which are located in C:\XML_Source_Files. Once the VBA completes the change it saves the edited XML file to this directory, C:\output.
The actual change I need the VBA to perform is a cut and paste operation. The CUT operation requires the VBA to select an XML block by the openingXML tag and closing<referencedApplicGroup>XML tag. Additionally, the CUT operation also needs to include the <data> tags in between as well (see example XML block shown below in the BEFORE state).</referencedApplicGroup>
With the cut operation complete I then need the VBA to PASTE the same XML block to a new location. The target location is in front of the opening<upstream XML tag data> <applic> <referencedApplicGroup> <data> <para>Example Text</para> </data> <data> <para>Example Text</para> </data> </referencedApplicGroup> </applic> <downstream XML tag data>XML tag. The example below shows how the XML should like after the PASTE operation is complete (the AFTER state):<content>
Can a VBA perform such an operation? I ask because I learned a Regular Expression cannot do it. Nevertheless, I would be very grateful if anyone out there would be kind enough to help me develop this VBA I call an "XML Block Relocator" because I do not have the advanced VBA skills needed to create such a VBA. I'm sure it will not only help me but also many of the members belonging to this forum who have a lot of TEXT edits to perform across hundreds of TEXT files. Thanks in advance for your help.<upstream XML tag data> <referencedApplicGroup> <data> <para>Example Text</para> </data> <data> <para>Example Text</para> </data> </referencedApplicGroup> <content> <downstream XML tag data>