I want to automate a script that parses an XML file and copy a section of it. I searched and found a way to do that but its working only with fields like
<title> .... </title>
My aim is to copy this
<datasource enabled="true" jndi-name="java:/db_namePostgresDS" jta="true" pool-name="db_namePostgresDS" spy="false" use-ccm="false" use-java-context="true">
THINGS AND FIELDS IN HERE
</datasource>
and paste it just after </datasource>
. Then I will change values with sed. But I basically want to double that section.
I just can't get how to do it, and maybe it's an XY Problem. Any help?
EXAMPLE:
I have
<datasource enabled="true" jndi-name="java:/db_namePostgresDS" jta="true" pool-name="db_namePostgresDS" spy="false" use-ccm="false" use-java-context="true">
THINGS AND FIELDS IN HERE
and I want to have
<datasource enabled="true" jndi-name="java:/db_namePostgresDS" jta="true" pool-name="db_namePostgresDS" spy="false" use-ccm="false" use-java-context="true">
THINGS AND FIELDS IN HERE
</datasource>
<datasource enabled="true" jndi-name="java:/MODIFIED_NAME_HERE_PostgresDS" jta="true" pool-name="db_namePostgresDS" spy="false" use-ccm="false" use-java-context="true">
MODIFIED THINGS AND FIELDS IN HERE
</datasource>
Important: I need to avoid installing new software on the machine (explicit customer request). XML parsers, if not built-in, aren't the way.