1
votes

I am struggling now with the following task. I am trying to remove empty XML entry with use of XMLStarlet.

What I trying is to use this XPATH:

//*[not(./*) and (not(./text()) or normalize-space(./text())='')]

I've tested it on http://www.freeformatter.com/xpath-tester.html and it works as expected. Mated together with XMLStarlet doesn't work:

xmlstarlet ed -d '//*[not(./*) and (not(./text()) or normalize-space(./text())='')]'

What could be the reason of that?

1
In what way it didn't work? Please provide sample XML to test...har07

1 Answers

2
votes

Try to use quotes in double quotes or vice versa.

For your example:

xmlstarlet ed -d '//*[not(./*) and (not(./text()) or normalize-space(./text())="")]'

or

xmlstarlet ed -d "//*[not(./*) and (not(./text()) or normalize-space(./text())='')]"