How do I write the Device ID and Mac Address to an XML file on the SD Card? Is that possible?

Solved

How do I write the Device ID and Mac Address to an XML file on the SD Card? Is that possible? 

Here is what I have so far from, but i'm not sure how to get this in a XML file on the device:

function getDeviceId() {
return mobicontrol.device.id;
}

var deviceId = getDeviceId();
mobicontrol.log.info("Device ID: " + deviceId);
a year ago
Android Scripting
ANSWERS
R
Robert
a year ago

Hi Katie,
Here is an example to look at how to write the info to an textfile and formatting it as XML.

var devID = mobicontrol.device.id;
var devMAC = mobicontrol.device.macAddress;

var xmlString = '<?xml version="1.0" encoding="utf-8"?>\n' +
'<deviceinfo>\n' +
'  <device id="' + devID + '"/>\n' +
'  <device macaddress="' + devMAC + '"/>\n' +
'</deviceinfo>';

var xmlFile = new mobicontrol.io.File('/sdcard/myXMLfile.xml');
xmlFile.writeText(xmlString);

Solution
KW
Katie Williams Bronze Contributor
a year ago

Robert, thanks so much! This is my first use case for JS that I've actually understood and will be able to implement! Many thanks to you and the SOTI Community as a whole!! :) I'm too excited lol! Thank you Jesus!!