How to remove xml namespace from xml file using shell script?

I have an xml file:
<AutoData xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Table1>
<Data1 10 </Data1>
<Data2 20 </Data2>
<Data3 40 </Data3>
<Table1>
</AutoData>
and I have to remove the portion xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" only.

I tried using sed command like:
sed 's% xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"%%' old.xml >new.xml
but didnot work.
Any help will be much appreciated.
TIA.

It works for me...

$ echo '<AutoData xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">'
<AutoData xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
$ echo '<AutoData xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">' | sed 's% xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"%%'
<AutoData>
$

Similar code I've in my shell script. But when I'm re-directing this command to a new xml file, it creates a file of size 0. The file is big in size, can that be a reason?

TIA.

I doubt it. But why not try a small test data file?

Tested it with a small file. I works! But when I'm using a larger file, it stops working.

I don't see why that would be. Try simply copying the large file to the output file. Maybe you are out of disk space or something like that.

Did that too. File got copied as expected. But with this command, it generates a file of 0 byte! And it works only for smallers sized files. I'm getting confused here.


awk '/<AutoData/{print $1">";next}1' file

Any help regarding this will be great. Still waiting for a solution from the unix gurus here.
TIA.

used awk '{ gsub(/ xmlns:xsi\=\"http:\/\/www.w3.org\/2001\/XMLSchema-instance"/,"") } 1' file.
It worked. Thanks.

Shorter:

sed '/<Auto/s/\(.*\) .*/\1>/' file