dhtmlxChart dynamic xml data from asp

I’m attempting to build a dynamic xml file with asp and pass it to dhxmlx charts. However the dhtmlxChart script doesn’t seem to recognize the asp generated xml file.

ASP generated XML file (xml_projects.asp):

Response.ContentType = "text/xml" 
Response.write("<?xml version='1.0' encoding='ISO-8859-1'?>"&vbcrlf)
	
		SQL = "Select hours, scope FROM projects"
		Set rs = oConn.Execute(SQL)
		
		Response.Write( "<data>"&vbCrlf)
			itmCnt = 1
			while NOT rs.EOF 
				Response.Write(vbTab& "<item id="""&itmCnt&""">"&vbCrlf)
				for i=0 to rs.Fields.Count-1
					Response.Write(vbTab&vbTab& "<"&rs(i).Name&">"&rs(i)&"</"&rs(i).Name&">"&vbCrlf)
				next
				Response.Write(vbTab& "</item>"&vbCrlf)
				itmCnt = itmCnt + 1
			rs.MoveNext()
			wend
		Response.Write( "</data>")

Content from the output page

<script>
	var barChart;
	window.onload=function(){
		barChart =  new dhtmlXChart({
			view:"bar",
			container:document.getElementById("chart_container"),
	   		value:"#hours#",
			label:"#hours#",

			xAxis:{
				title:"<%=Request.QueryString("v")%> Hours by Activity <br><%=MonthName(Request.QueryString("m"))%> 2010",
				template:"#scope#",
				lines: true
			},
			yAxis: {
				start: 0,
				end: 300,
				step: 25,
				title: "Hours"
			} ,

        tooltip: {
            template: "#hours#"
        },

			padding:{
				bottom:60,
			},
			width:30,
			gradient:true,
			border:true
		})
		barChart.load("xml_projects.asp");
	}

</script>
<div id="chart_container" style="width:800px;height:400px;border:1px solid #A4BED4;float:left;margin-right:20px"></div>

I’m assuming it’s something wrong with my dynamically generated data, because if I create an xml file from asp with dummy data the chart works fine.

Many Thanks!

Try to load xml_projects.asp directly in browser - is it correctly loads and renders as XML ?
If issue still occurs for you - attach the sample of problematic XML - so far your code looks correct, but may be there are some special chars in your data which corrupts xml.

Stanislav,
Thanks for the reply. The xml appears to be fine in the browser. I’ve attached the xml in question.

Items “1” & “2” are hard coded into the xml_project.asp page and the chart renders these items fine, items above two do not render in the chart and are pulled dynamically.

I have also taken the xml and created an actual xml file and the chart renders the data fine.

<?xml version='1.0' encoding='ISO-8859-1'?>
<data>
	<item id="1">
		<hours>133</hours>
		<scope>test</scope>
	</item>
	<item id="2">
		<hours>43.5</hours>

		<scope>Data Prep/Manipulation</scope>
	</item>
	<item id="3">
		<hours>43.5</hours>
		<scope>Data Prep/Manipulation</scope>
	</item>
	<item id="4">

		<hours>3</hours>
		<scope>Meetings</scope>
	</item>
	<item id="5">
		<hours>28.25</hours>
		<scope>Production</scope>
	</item>

	<item id="6">
		<hours>11</hours>
		<scope>Project Research</scope>
	</item>
	<item id="7">
		<hours>43.5</hours>
		<scope>Scripting</scope>

	</item>
	<item id="8">
		<hours>251</hours>
		<scope>UAT</scope>
	</item>
</data>

Thanks for your support!

Stanislav,
:blush: Please disregard this request, it appears to be a user issue (me!) :blush:

I was passing the queried data to the xml_projects.asp page incorrectly by treating the xml file as an “included” file. I was forgetting to pass the querystring data in the xml call

Error:

 barChart.load("xml_projects.asp");

Corrected:

 barChart.load("xml_projects.asp?dt=8-1-2010");

Thank you for your time & support.
mwhiz