Ok, an other option.
If I understand you last post correctly this should do the trick.
This one checks if both the start and end test tags are in the line. If so it changes the contents of $line to the new stuff including the start and end test tags. Both the tags should be on the same line with the value if not this script fails. A rewrite of the entire xml file with a modified to your situation version of the script I posted above is the road I would try to walk on. Reading and writing xml with kix is new and has not been heavily used before afaik. Shawn, Jim and Jose did some stuff with this but it kind of faded out a little. Recently I picked up reading and writing xml as xml and not text using kix again because we have several projects at work that we can use this for but for me it's also a path full of surprises and new stuff. Learning something new almost each time I use it.
I changed the brackets around test and /test because the board keeps eating them. You should change it back to the proper brackets before using the code.
Code:
Break on
;
$sourcefile = "d:\XMLfile.xml"
$newfile = "d:\newXMLfile.xml"
;
$rc = Open (1, $sourcefile, 2)
$rc = Open (2, $newfile, 5)
;
$line = ReadLine (1)
While @ERROR = 0
If InStr($line, "{test}") AND InStr($line, "{/test}")
$line = "{test}The new stuff should be here{/test}"
EndIf
$rc = WriteLine (2, $line + @CRLF)
$line = ReadLine (1)
Loop
;
$rc = Close(1)
$rc = Close(2)
_________________________
Mart
- Chuck Norris once sold ebay to ebay on ebay.