Results 1 to 3 of 3
i need to delete a block of text containing a regex
for instance I have a xml file which is:
<item>
<key>166</key>
<value>x</value>
</item>
<item>
<key>200</key>
<value>y</value>
</item>
i need ...
- 04-06-2010 #1Just Joined!
- Join Date
- Feb 2010
- Posts
- 14
sed command
i need to delete a block of text containing a regex
for instance I have a xml file which is:
<item>
<key>166</key>
<value>x</value>
</item>
<item>
<key>200</key>
<value>y</value>
</item>
i need to delete the item(block of text between <item> and </item> containing the key 166 so how can I make use of sed here
Can someone please provide the sed command to be used?
- 04-07-2010 #2Linux Newbie
- Join Date
- Apr 2010
- Location
- Novosibirsk, Russia
- Posts
- 136
- 04-07-2010 #3
You may be able to write a regular expression to do this for specific and simple cases, but general XML parsing and understanding cannot be done with regular expressions. Your best bet would be to use a full XML parser that could delete the necessary elements and create a new XML document.
DISTRO=Arch
Registered Linux User #388732


Reply With Quote
