how to delete text from a xml file

November 9, 2012 at 10:30:10
Specs: Windows Vista
how to delete all the text from xml file which are not in xml tag through cmd batch (.bat)

See More: how to delete text from a xml file

Report •


#1
November 16, 2012 at 10:35:27
Probably difficult to minipulate data in xml format through a batch.

What is the line you are trying to draw from(an example line would be great here)? What from the line are you looking to aquire?

From this it would be possible to attempt it I would say, however depending on the length of the file it might exceed the capacity.

thanks,

:: mike


Report •

#2
November 16, 2012 at 15:39:49
I made this script some time ago to parse xml into tag-content and data-content. Maybe you can make it work - it is not recommended to use batch for xml. Most other languages are much more proficient and less error-prone, including vbscript (which is non-compiled and runs from the command-line like batch).
::===== begin script
@echo off & setlocal enabledelayedexpansion
:: parse xml /html into tags and content

for /f "tokens=*" %%z in (test.xml) do (
set test=%%z
set xx=
set z=1
set y=2
call :aaa
)
echo done
goto :eof

:aaa
for /f "tokens=%z%,%y% delims=<" %%a in ("%test%") do (
set f=%%b
set s=%%a
call :bild
)

if "%f%" equ "" >>xml.out echo !xx! & goto :eof
set /a z+=1
set /a y+=1
goto :aaa

:bild
for /f "tokens=1,2 delims=>" %%c in ("%s%") do (
rem echo TAG:%%c DATA:%%d
set xx=!xx!^<%%c^>
)
::=== end script
this more holes than blackburn lancashire (they had to count them all), so...
no guarantees, no warranty, no returns, no-money-back, use at your own risk, don't try this at home, warning: may be hazardous to small childern and pets, DANGER WILL ROBINSON!! blah blah blah you get the idea. ;-)


Report •

Related Solutions


Ask Question