I am trying to create a chart (with amCharts) from data we store in one of our internal Sharepoint lists.
These lists can thankfully be converted to a XML format via a RESTful URL query. These queries look like this:
https://sharepoint/_vti_bin/owssvr.dll?Cmd=Display&List=%7B812FC713-F916-4284-B50F-2EC3B8E80C98%7D&View=%7BAAFAA130-33B1-4A21-9E98-C25FECEF79E4%7D&XMLDATA=TRUE?Cmd=Display&List=%7B812FC713-F916-4284-B50F-2EC3B8E80C98%7D&View=%7BAAFAA130-33B1-4A21-9E98-C25FECEF79E4%7D&XMLDATA=TRUE
The resulting XML data doesn't have a standard header / mime-type / etc. though and goes like:
<xml xmlns:s='uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882'
xmlns:dt='uuid:C2F41010-65B3-11d1-A29F-00AA00C14882'
xmlns:rs='urn:schemas-microsoft-com:rowset'
xmlns:z='#RowsetSchema'>
<s:Schema id='RowsetSchema'>
...
</s:Schema>
<rs:data>
...
</rs:data>
</xml>
Now what I need to do in order to transform and work with the data in javascript, so that I can ultimately insert it into the chart, is to be able to parse it in my web application (html / php / plain js).
Normally I'd do a xmlhttprequest() in this case, however, I have tried this already and it failed me. Seemingly it can't utilize an URL as the xml source. Unfortunately there aren't any error messages either...
Here's the function I've used (including debug alerts):
<script type="text/javascript">
function loadXMLDoc(XMLname)
{
alert("Function loaded");
var xmlDoc;
if (window.XMLHttpRequest)
{
alert("Chrome, getting XML");
xmlDoc=new window.XMLHttpRequest();
xmlDoc.open("GET",XMLname,false);
xmlDoc.send("");
alert("Chrome, got XML");
return xmlDoc.responseXML;
}
// IE 5 and IE 6
else if (ActiveXObject("Microsoft.XMLDOM"))
{
alert("IE, getting XML");
xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.async=false;
xmlDoc.load(XMLname);
alert("IE, got XML");
return xmlDoc;
}
alert("Error loading document!");
return null;
}
</script>
The function loads correctly, then correctly chooses the Chrome/Firefox path and starts requesting the data via a "GET" query.
This query doesn't ever give back a result or error message though and the
alert("Chrome, got XML");
is never reached.
Does anyone have any idea why there are no error messages or how to actually parse a XML URL with javascript?
best regards
daZza