Hi ppl!
I'm trying to do a very simple thing - I have an xml file and I wish to add another line to it, using a batch file.
The xml file is named: 1.xml and it looks like that:
<?xml version='1.0' encoding="UTF-8"?>
<start>hello</start>
I'm using the following code to add another line between the first line and the second:
@echo off > newfile
set /a lineNUM=0
for /f "tokens=*" %%L in (1.xml) do call :sub1 %%L
copy newfile 1.xml > nul
del newfile
goto :eof
:sub1
set /a lineNUM+=1
if %lineNUM% EQU 2 echo ^<?format="my"?^> >> newfile
echo %* >> newfile
Problem is that the xml tag is ruining this whole edit process.
Any idea how to solve this?
Thanks!
Orik.
Copy and edit xml file using batch
Moderator: DosItHelp
Re: Copy and edit xml file using batch
Code: Select all
@echo off
find "?xml version='1.0' encoding=" <"file.xml" >"newxmlfile.xml"
echo ^<?format="my"?^> >>"newxmlfile.xml"
more +1 <"file.xml" >>"newxmlfile.xml"
Re: Copy and edit xml file using batch
foxidrive wrote:Code: Select all
@echo off
find "?xml version='1.0' encoding=" <"file.xml" >"newxmlfile.xml"
echo ^<?format="my"?^> >>"newxmlfile.xml"
more +1 <"file.xml" >>"newxmlfile.xml"
This is very smart

Re: Copy and edit xml file using batch
Foxidrive,
That's working great!
Both genius and simple as hell, why didn't I come up with that?
Thanks!
Orik.
That's working great!
Both genius and simple as hell, why didn't I come up with that?

Thanks!
Orik.