我有具有許多元素評論XML文件。從所有這些元素中,我想使用sed命令取消註釋一個元素。取消註釋XML塊
我有XML文件:
<!-- This is the sample xml
which holds the data of the students -->
<Students>
<!-- <student>
<name>john</>
<id>123</id>
</student> -->
<student>
<name>mike</name>
<id>234</id>
</student>
<!-- <student>
<name>NewName</name>
<id>NewID</id>
</student> -->
</Students>
在上面的XML文件,我想取消註釋最後一個XML塊,所以我的文件看起來像
<!-- This is the sample xml
which holds the data of the students -->
<Students>
<!-- <student>
<name>john</>
<id>123</id>
</student> -->
<student>
<name>mike</name>
<id>234</id>
</student>
<student>
<name>NewName</name>
<id>NewID</id>
</student>
</Students>
我通過sed命令不見了,但沒有得到如何從最後一個塊刪除<!--
和-->
。 <name>
爲NewName
是否可以取消註釋xml塊?除了刪除整行之外,我沒有發現任何東西。
編輯:我可以有許多xml元素,而不是<name>
和<id>
像<address>, <city>, <class>,<marks>
。
在你只輸入第一個'student'被評論所包圍。第三不是。實際上,輸入不是有效的XML。 –
我已經更新了這個問題。錯誤地在這裏輸入了錯誤。但問題仍然存在 –
我懷疑你想做什麼是可能的。解析XML很困難。 –