How to copy multiple .xml lines...

Started by sst001, March 19, 2015, 07:44:37 AM

Previous topic - Next topic

sst001

Hi All, I'd like to replace a the string </Pluins> in a production.xml with multiple lines copied over from a template.xml.

These are the lines from the template.xml I would like to copy over - keeping format if possible - to the production.xml:

Quote
    <Instance ID="a58230c9-48c9-88888c-9b97-15ff1135a340" DisplayName="ART5" PIType="GetHost" DLL="RegExPlugIn.dll" TypeName="RegExPlugIn" MaxQueue="999" ConfigFile="false" AskDNS="When" Rev="0">
      <Config>&lt;match regex=".*" ip="127.0.0.1" ttl="1800" /&gt;</Config>
      <AskDNSWhen Type="1" MatchAll="true">
        <Rule Type="14" PlugInID="75e20c2d-5dcf-428d-88888a-442e0de97e96" />
        <Rule Type="22" Not="true" PlugInID="de069abd-b247-495c-849f-777910a2efef" />
        <Rule Type="22" PlugInID="fb2c679d-51a8-4199-879a-51c156249a11" />
      </AskDNSWhen>
    </Instance>
  </PlugIns>

I'm using the following code which works great for a single line, but not for multiple lines.  I've played with the buffer sizes but still can't get it working.

Code (winbatch) Select


handle = FileOpen("c:\ac_dns1\work\template.xml", "READ")
rep = FileRead(handle)

str="</PlugIns>"
dafile="C:\ac_dns1\work\sdnsplus.config.xml"
fs = FileSize( dafile )
binbuf = BinaryAlloc( fs+900000 )
ret = BinaryRead( binbuf, dafile )
num = BinaryReplace( binbuf, str, rep ,0)
BinaryWrite( binbuf, dafile )
BinaryFree( binbuf)
fileclose (handle)


Maybe this can't be done, replacing a single string with multiple strings? Any direction greatly appreciated.

Thanks in advance,
ST


td

The 'FileRead' function will only read on line of text from a file at a time.  You might want to consider using the 'FileGet' function instead. 
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

sst001