Hi,
I created a metro style app using JavaScript. In my application i am calling an api that returns a xml. I used the following codes to parse a xml and the result is successfully displayed in my html page.
function loadRemoteXhr() {
document.getElementById("xhrOutput").innerHTML = "";
WinJS.xhr({
url: "http://api.eventfinder.co.nz/categories/list",
user: 'xxxxx',
password:'xxxxx'
}).then(
xhrParseXml, xhrError
);
}
function xhrParseXml(result) {
var outputArea = document.getElementById("xhrOutput");
var xml = result.responseXML;
if (xml) {
var items = xml.querySelectorAll("categories > category");
if (items) {
var length = Math.min(10, items.length);
for (var i = 0; i < length; i++) {
var link = document.createElement("a");
var newLine = document.createElement("br");
link.setAttribute("href", xml.getElementsByTagName("category")[i].childNodes[0].nodeValue);
link.innerText = (i + 1) + ") " + xml.getElementsByTagName("category")[i].childNodes[0].nodeValue;
var _maincategory = xml.getElementsByTagName("category")[i].childNodes[0].nodeValue;
outputArea.appendChild(link);
outputArea.appendChild(newLine);
}
} else {
outputArea.innerHTML = "There are no items available at this time";
}
} else {
outputArea.innerHTML =
"Unable to retrieve data at this time. Status code: " + statusCode;
}
}
But i want to bind xml to list view.
Is it possible to bind xml directly to the ListView in javascript metro app??
Help me please,
Thanks.