Paweł Zakrzewski
Paweł Zakrzewski

Reputation: 41

XPATH and XMLStarlet

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?

Upvotes: 1

Views: 514

Answers (1)

lauda
lauda

Reputation: 4173

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())='')]"

Upvotes: 2

Related Questions