0

I have an xml that starts like that

<?xml version="1.0"?><History xmlns="http://www.tandberg.no/XML/CUIL/1.0">

And i'm having problem selecting elements in it because of this namespace. I want to select it and delete using xmlstarlet.

I tried:

xmlstarlet ed -d '//@xmlns' history.xml
xmlstarlet ed -d '//@[local-name()=xmlns]' history.xml

But all the time i get "xpath set is empty"

habichp
  • 3
  • 3

1 Answers1

0

Namespace declarations aren't attributes in the XPath data model, so you can't select them as if they were.

"Deleting a namespace" is actually changing the name of the element, from a name in a specific namespace, to a name in no namespace. I don't know xmlstarlet, but you need to be looking for a "rename" action.

Michael Kay
  • 156,231
  • 11
  • 92
  • 164