Hi there,
Im working on a script to parse elements from a url based xml that has login based authentication.
I cant seem to add authentication to the OGscript and the debug is indicating error 401 so it has not worked.
Below is the original code that has no credentials added at all, If anyone could please indicate the correct way to input credentials to be used with the ogscript.parseXML command that would be amazing.
var XMLDoc;
ogscript.debug(params.getValue('XMLPath', 0));
var FilePath = params.getValue('XMLPath', 0).replace(/\\/g, '/').replace(/"/g, '');
ogscript.debug('Formatted File Path: ' + FilePath);
ogscript.debug('Reading XML file...');
XMLDoc = ogscript.parseXML('Http://' + FilePath);
if (!XMLDoc) {
ogscript.debug('Failed to read file');
} else {
ogscript.debug('Parsing XML');
var nodeList = ogscript.runXPath('//teamPlayer', XMLDoc);
if (nodeList && nodeList.getLength && nodeList.getLength() > 0) {
ogscript.debug('Found ' + nodeList.getLength() + ' players.');
for (var i = 0; i < nodeList.getLength(); i++) {
var player = nodeList.item(i);
var playerID = String(player.getAttribute('playerId')); // Convert to string
var playerName = String(player.getAttribute('playerName')); // Convert to string
// Store values in parameters with index (0 is default index)
params.setValue('PlayerID_' + i, 0, playerID);
params.setValue('PlayerName_' + i, 0, playerName);
}
} else {
ogscript.debug("No players found in XML.");
}
}
------------------------------
Sam Ebert
Tech manager / Xpression Designer
KOJO
------------------------------