Wednesday 15 February 2012

Replace two text string that assigned to variables with each other in XML document -



Replace two text string that assigned to variables with each other in XML document -

i have test.xml document :

<?xml version="1.0" encoding="utf-8"?> <flashget> <downloads> <item1> <url>http://host.com/test.zip</url> <parentdir>1</parentdir> <name>test.zip</name> <referer>http://host.com/myfiles</referer> <sendreferrer>0</sendreferrer> <maxsegments>15</maxsegments> <attempts>25163</attempts> <url>http://host2.com/test2.zip</url> <elapsedtm>1073426633</elapsedtm> <filedate>0</filedate> <resumable>1</resumable> <browser>1766278484</browser> <saveredirurl>0</saveredirurl> <preservefiledate>0</preservefiledate> <applysizerules>0</applysizerules>

i need replace text string assigned variables $l1 text string assigned $r1 variable within .xml document.

showing text string assigned variables : (text string assigned variables changes , that's why utilize )

echo %l1% http://host.com/test.zip echo %r1% http://download.com/book.zip

so new output.xml should :

<?xml version="1.0" encoding="utf-8"?> <flashget> <downloads> <item1> <url>http://download.com/book.zip</url> <parentdir>1</parentdir> <name>test.zip</name> <referer>http://host.com/myfiles</referer> <sendreferrer>0</sendreferrer> <maxsegments>15</maxsegments> <attempts>25163</attempts> <url>http://host2.com/test2.zip</url> <elapsedtm>1073426633</elapsedtm> <filedate>0</filedate> <resumable>1</resumable> <browser>1766278484</browser> <saveredirurl>0</saveredirurl> <preservefiledate>0</preservefiledate> <applysizerules>0</applysizerules>

i using xmlsearchandreplace.

my own code not working:

xmlsearchandreplace.exe /o=en /s=%l1% /r=%r1% /f=d:\test.xml

/o=en searches element name, want search value, need utilize /o=ev. can set variables in file, , phone call using next command:

xmlsearchandreplace.exe /o=ev /f=d:\test.xml /p=d:\your_parameter_file.txt

in your_parameter_file.txt

/s="http://host.com/test.zip" /r="http://download.com/book.zip"

you can alter urls in your_parameter_file.txt appropriate.

to run without parameter file, call

xmlsearchandreplace.exe /o=ev /s=http://host.com/test.zip /r=http://download.com/book.zip /f=d:\test.xml

xml

No comments:

Post a Comment