i have an xml file on which i have to do modification basing on some rules and i want to know can we do that in the batch script. suppose the following is the sample of xml file
> > <conf-article article-type="research" content-type="----"
> > dtd-version="---" open-access="no" xml:lang="en" lifecycle="final">
> > <conf-front>
<conf-proc-meta>
<conf-proc-id
> > conf-proc-id-type="conf-acronym">cccc</conf-proc-id>
> > <conf-proc-title-group>
and i want to insert the following lines
<!--Delivery Date: 07/23/2013-->
<!--XML Script: sdfasdfdfs-->
<!--Batch: sdfsdfdssfs-->
before <conf-front>
tag.This is an example like that i have some more.so i need some help on this.
This will create temp.xml file and you can check if it fits on your needs and then copy it over your old file.Will set this before last
<conf-front>
tag so I hope there's only one of this kind.And changesome.xml
with the name of your xml everywhere in the code.EDIT ~ do this with all .xml in a folder (will not affect subfolders)
Just change
c:\some_dir
with your own path.And back-up your dir..Here is another solution to process a folder full of xml files.
It uses a helper batch file by Aacini called
findrepl.bat
from - https://www.dropbox.com/s/rfdldmcb6vwi9xc/findrepl.batPlace
findrepl.bat
in the same folder as the batch file, and remove theREM
to make the.tmp
version of the files overwrite the original files, after you test it.where q19559569.xml is your original and newfile.xml is created.
Batch is really not a suitable tool for the task.
I've assumed that by "before" you mean "on the line preceding that on which the nominated tag appears" and not "directly before the tag" - that is, between the leading
> >
and the tag.Since the inserted text nominated is clearly artificial, if the real text you require is placed in a file called say
insertme.txt
then replacing the threeECHO
statements withshould be more flexible.
This mod should produce a new file with extension
.new
from the existing.xml
files