I am attempting to create a script that wraps a Groovy class that will take the following arguments:
- An input XML file to update.
- An arbitrary snippet to insert into the input file (might not even be well-formed in an of itself; it would become part of a larger well-formed document).
- XPath for the marker element (used for positioning the snippet in #2).
- An action (insert before, insert after, append child).
- Optional output XML file.
I’m at a loss for finding an API that will allow me to:
- Find a node by XPath and
- Cram XML from a String adjacent to the node.
Does anyone have some ideas for technologies that I can combine to achieve this effect? Small examples would be especially useful.
I suspect what I was trying to do is non-trivial and would have required a much larger framework than what I had time for. I ended up abandoning this endeavor.