XML : Using SED to delete all XML elements which have certain values

I have a xml file with following lines:

  <connections>     <connection>        <name>connection1</name>        <server/>        <type>POSTGRESQL</type>        <access>JNDI</access>        <database>connections&#x2f;test&#x2f;connection1</database>        <port>-1</port>        <username/>        <password>Encrypted </password>     </connection>     <connection>        <name>test</name>        <server>asdf</server>        <type>ORACLE</type>        <access>Native</access>        <database>asdf</database>        <port>1521</port>        <username>asdf</username>        <password>zcv</password>     </connection>  </connections>    

What i want is the following output:

  <connections>     <connection>        <name>test</name>        <server>asdf</server>        <type>ORACLE</type>        <access>Native</access>        <database>asdf</database>        <port>1521</port>        <username>asdf</username>        <password>zcv</password>     </connection>  </connections>    

I can't use a xslt parser (like xmlstarlet) because it will parse the HTML code (/ becomes /).

i've tried it with SED:

sed -ne '/<connection>/+.*/<access>/JNDI<\/access>/[\s\S]+.*<\/connection>/d'

but no luck there. Hope anyone can help me.

No comments:

Post a Comment