I'm trying to remove a parent section using a string in a child's tag.
Section of the XML file (original.xml)
<Mods>
<ModItem>
<Name>296707746.sbm</Name>
<PublishedFileId>296707746</PublishedFileId>
</ModItem>
<ModItem>
<Name>294620323.sbm</Name>
<PublishedFileId>294620323</PublishedFileId>
</ModItem>
<ModItem>
<Name>295393216.sbm</Name>
<PublishedFileId>295393216</PublishedFileId>
</ModItem>
</Mods>
I need to remove the parent section of a child that matches <Name>numbers.sbm</Name>
tags Like this:
<ModItem>
<Name>294620323.sbm</Name>
<PublishedFileId>294620323</PublishedFileId>
</ModItem>
to produce this:
<Mods>
<ModItem>
<Name>296707746.sbm</Name>
<PublishedFileId>296707746</PublishedFileId>
</ModItem>
<ModItem>
<Name>295393216.sbm</Name>
<PublishedFileId>295393216</PublishedFileId>
</ModItem>
</Mods>
Current code i'm using:
FOR /f "tokens=1 delims=:" %%L in ('FINDSTR /n "<Name>294620323.sbm</Name>" sandboxxml.txt ') do set /a line=%%L-2
BREAK> "%temp%\empty"
FC "%temp%\empty" "sandboxxml.txt" /lb %line% /t | MORE +4 |FINDSTR /b /e /v "*****" >temp.xml
(the code is a modified answer from a different topic)
It adds everything before the section to temp.xml
How would i get the rest of the original.xml into temp.xml, excluding the removed section?
and is there a different/simpler way to achieve this?
( this is my first question on stackoverflow, sorry if i did something wrong!)