replacemnt of values in a xml document

Started by gikke, January 22, 2014, 07:25:08 AM

Previous topic - Next topic

gikke

Hi,

I have been using WinBatch for so many years and i did very nice things with it.
Right now i am a bit stuck, i want winbatch to replace a numerical value in an xml type document.
So what i want to do is read the file, locate the value using StrIndex and then replace a value somewhere where StrIndex located it and save the xml file.
I must say i am not an IT professional, rather a broadcast television engineer ...

Greetz, thanks,

Guy


Deana

I recommend using BinaryReplace. Simply make sure you allocate a large enough buffer to handle the new string data is longer than the existing data.

For Example:
Code (winbatch) Select
str="hello"
rep="goodbye"
dafile="C:\Temp\myfile.txt"
fs = FileSize( dafile )
binbuf = BinaryAlloc( fs+100 )
ret = BinaryRead( binbuf, dafile )
num = BinaryReplace( binbuf, str, rep ,0)
Message( "Number of '%str%' strings replaced", num )
BinaryWrite( binbuf, dafile )
BinaryFree( binbuf)
Exit


See also:
http://techsupt.winbatch.com/webcgi/webbatch.exe?techsupt/tsleft.web+WinBatch/XML+XML~Search~and~Replace.txt
Deana F.
Technical Support
Wilson WindowWare Inc.