Is it possible to delete duplicate parts in an xml file? This forum doesn't use the normal code tags, so I don't know how to paste an example. Try and imagine an xml file with these 3 blocks...
I can't think of an easy way to deduplicate all ids though.
Also quick question, why does an xml file with in > it give the error "Unseported version '1.1'"? Is there anything I can do about that?
The underlying libxml is giving this error. You can either change to version 1.0, or use -q option to suppress all errors. Ideally libxml would be updated to support version 1.1, but I don't think that's likely to happen...
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Is it possible to delete duplicate parts in an xml file? This forum doesn't use the normal code tags, so I don't know how to paste an example. Try and imagine an xml file with these 3 blocks...
/xml/table/rec id="2"/numField, stringField
/xml/table/rec id="2"/numField, stringField
/xml/table/rec id="3"/numField, stringField
Can the duplicate block be deleted to give...
/xml/table/rec id="2"/numField, stringField
/xml/table/rec id="3"/numField, stringField
Also quick question, why does an xml file with in it give the error "Unseported version '1.1'"? Is there anything I can do about that?
Sorry, I somehow missed this post. The forum now uses markdown, see https://sourceforge.net/p/xmlstar/discussion/markdown_syntax.
Given this
xmlstarlet ed -d "//rec[@id = 2][position() > 1]" table.xmlgivesI can't think of an easy way to deduplicate all ids though.
The underlying libxml is giving this error. You can either change to version 1.0, or use
-qoption to suppress all errors. Ideally libxml would be updated to support version 1.1, but I don't think that's likely to happen...