Hi I have this problem that I first thought was easy, but now I don't. I have a file with multiple procedure elements. Within each element are multiple clstep elements. I need to capture the procedure element and iterate through each clstep element and modify that elements children. I've got the capture of the procedure element figured out, but I'm drawing a blank on how to capture and manipulate the clstep children. Does UES have any type of XML node functions?
Thank you for your help,
Max
Sample XML:
Code so far
Thank you for your help,
Max
Sample XML:
Code: Select all
<procedure id="proc1" next-id="proc2">
<title>Crewstation</title>
<clstep1 id="clstepAtt">
<challenge>HDR</challenge>
<response>MUTE</response>
<role>P, Cole</role>
<page></page>
<pane></pane>
</clstep1>
<clstep1>
<challenge>Light switch</challenge>
<response>OFF</response>
<role>P, SO</role>
<page></page>
<pane></pane>
</clstep1>
<end/>
</procedure>
Code: Select all
function XMLConv() {
//Define environment for this script.
if (UltraEdit.document.length > 0) //Is any file opened?
{
// Define environment for this script.
UltraEdit.insertMode();
if (typeof(UltraEdit.columnModeOff) == "function") UltraEdit.columnModeOff();
else if (typeof(UltraEdit.activeDocument.columnModeOff) == "function") UltraEdit.activeDocument.columnModeOff();
UltraEdit.selectClipboard(8);
//Get document index number
var nActiveFileIndex = UltraEdit.activeDocumentIdx;
UltraEdit.perlReOn();
UltraEdit.document[nActiveFileIndex].top();
UltraEdit.document[nActiveFileIndex].findReplace.mode = 0;
UltraEdit.document[nActiveFileIndex].findReplace.matchCase = false;
UltraEdit.document[nActiveFileIndex].findReplace.matchWord = false;
UltraEdit.document[nActiveFileIndex].findReplace.regExp = true;
UltraEdit.document[nActiveFileIndex].findReplace.searchDown = true;
UltraEdit.document[nActiveFileIndex].findReplace.searchInColumn = false;
UltraEdit.document[nActiveFileIndex].top();
while (UltraEdit.document[nActiveFileIndex].findReplace.find("<procedure")) {
//Remember in two variables the current caret position of
//the chapter beginning in file. There is nothing selected!
var nChLine = UltraEdit.document[nActiveFileIndex].currentLineNum;
//UltraEdit.activeDocument.key("HOME");
var nChColumn = UltraEdit.document[nActiveFileIndex].currentColumnNum;
if (UltraEdit.document[nActiveFileIndex].findReplace.find("</procedure>")) {
UltraEdit.activeDocument.key("RIGHT ARROW");
UltraEdit.document[nActiveFileIndex].gotoLineSelect(nChLine, nChColumn);
var procedure = UltraEdit.document[nActiveFileIndex].selection;
var Regex = /<clstep.*?>.*?<\/clstep1>/img;
var clStep = Regex.exec(procedure);
while (clStep != null) {
UltraEdit.outputWindow.write("clStep " + clStep[0]);
clStep = Regex.exec(procedure);
}
UltraEdit.outputWindow.write("Outside of clStep while");
}
}
}
}
XMLConv();