Reputation: 57
I want to delete the whole xml tag including the content . But only the first 2 lines are getting deleted. sed or awk is okay
<Resource name="jdbc/TestDB" auth="Container" type="javax.sql.DataSource"
maxTotal="100" maxIdle="30" maxWaitMillis="10000"
username="javauser" password="javadude"
driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost:3306/javatest"/>
After trying out the sed command sed -i "/Resource/,/[^\/>]/d" test.xml
I am left over with
username="javauser" password="javadude" driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost:3306/javatest"/>
Upvotes: 1
Views: 611
Reputation: 88563
With xmlstarlet:
xmlstarlet edit --delete '//path/to/your/tag' file.xml
Upvotes: 1
Reputation: 12662
This will do what you want
sed '/<Resource /{:a;N;/\/>/!ba};/<Resource/d' test.html
Upvotes: 0