Search code examples
javascripttoastwin-universal-appxmldocumentwindows-10

loadXml returns undefined on Windows 10


I'd like to create a custom toast, like Cortana uses, in my Windows 10 Universal App. Therefore I'm trying to pass a custom XML Snippet to the ToastNotification Class.

var xmlDocument = new Windows.Data.Xml.Dom.XmlDocument();

var xml = "<toast><visual></visual></toast>";
var toastXml = xmlDocument.loadXml(xml);

// var toast = new notifications.ToastNotification(xmlDocument.loadXml(xml));
// var toastNotifier = notifications.ToastNotificationManager.createToastNotifier();
// toastNotifier.show(toast);

But sadly xmlDocument.load(xml) always returns undefined. What am I doing wrong?


Solution

  • You're supposed to use the populated XmlDocument variable instead of using the return value of loadXml, something like :

    xmlDocument.loadXml(xml);
    var toast = new notifications.ToastNotification(xmlDocument);