Hello,
I have a large XML file (150 MB) containing nested XML nodes. Some of the nodes contain coordinates. Those have to be compared to a fixed value and changed if the coordinates exceed the value (trigger). The nodes in question are:
The three numbers in the node can be integer, float or 0. The first and third value have to be compared.
The written script does not produce any error but it does not change the values. To see whether I get an output I put "new" in front of the new XML node.
Can someone tell me what I did wrong?
Kind regards
I have a large XML file (150 MB) containing nested XML nodes. Some of the nodes contain coordinates. Those have to be compared to a fixed value and changed if the coordinates exceed the value (trigger). The nodes in question are:
Code: Select all
<Position>1114.25 0 1198.6755</Position>
<Position>1214.25 0 1034</Position>
<Position>200.455 1200.35 111.55</Position>
<Position>1152 65.33 1179.76</Position>The written script does not produce any error but it does not change the values. To see whether I get an output I put "new" in front of the new XML node.
Code: Select all
UltraEdit.insertMode();
UltraEdit.perlReOn();
UltraEdit.activeDocument.top();
UltraEdit.activeDocument.findReplace.mode=0;
UltraEdit.activeDocument.findReplace.matchCase=false;
UltraEdit.activeDocument.findReplace.regExp=true;
var trigger = 1152.0
var expandby = 448.0
var regex = /(<Postion>)([0-9]*\.?[0-9]*)\s([0-9]*\.?[0-9]*)\s([0-9]*\.?[0-9]*)(<\/Postition>)/g;
while ( UltraEdit.activeDocument.findReplace.find(regex) && ! UltraEdit.activeDocument.isEof() ) {
UltraEdit.activeDocument.selectLine();
var line = UltraEdit.activeDocument.selection;
var coor = line.match(regex);
var xCoor = Number(coor[2]);
if ( xCoor >= trigger ) {
xCoor = xCoor + expandby
}
var yCoor = Number(coor[4]);
if ( yCoor >= trigger ) {
yCoor = yCoor + expandby
}
var node = "new <Postion>"+xCoor+" "+coor[3]+" "+yCoor+"<Postion>";
UltraEdit.activeDocument.deleteLine();
UltraEdit.activeDocument.write(node);
}Kind regards


