Here’s a sample script if someone can correct where I’m going wrong. The code below will produce “null” “not an object” or “object required” errors depending on options I try. I’ve tried various options for creating the xml object, but can’t seem to get it right and then read data from nodes and attributes.
var text = "<bookstore><book type=\"Paperback\">" + "<title>Everyday Italian</title>" + "<author>Giada De Laurentiis</author>" + "<year>2005</year>" + "</book></bookstore>"; /* tried this as well but didn't work parser = new DOMParser(); xmlDoc = parser.parseFromString(text,"text/xml"); */ var xmlDoc = new ActiveXObject("Microsoft.XMLDOM"); xmlDoc.async="false"; xmlDoc.load(text); var xTitle = xmlDoc.getElementsByTagName("title").childNodes.nodeValue; Watch.Log(xTitle, 2); //expected title node result is Everyday Italian //also tried Watch.Log(xTitle.text, 2); var xType = xmlDoc.getElementsByTagName("book").getAttribute('type'); Watch.Log(xType, 2); //expected type attribute result is Paperback
Appreciate the help!