|
-
Jul 8th, 2002, 01:46 AM
#1
Thread Starter
Member
Accessing XML data easily?
Hi
I am a bit of a newbie when it comes to xml. I was wondering how one would go about doing the following.
I want to have an xml file containing certain information about reports that i want to display on my website. The xml file will contain some formating and other information for each report. When a user comes to the site, they choose a reportto view. That report name is then an imput variable.
What i want to know is, given the input value, how can i easily access that reports information stored in the xml file? Is there an object that i can create that i can just pass the value to, and it will return the hierachical information associated with that specific report named in the file? Then how do i easily access that information as well?
The information will then be passed to a report generation engine that will actually generate the reports.
Any help ( links to tutorials, or other info ) would be greatly appreciated. Thanks in advance.
Asterisk
-
Jul 8th, 2002, 06:01 AM
#2
Fanatic Member
This can be done in many different ways. You could use script to point the user to an html page with bound data controls, or you could use different xslt's based on the report parameter etc.
Lets start with a basic one. This is the xml
Code:
<customers>
<cust>Anne</cust>
<cust>shunt</cust>
<cust>john</cust>
</customers>
<orders>
<ord>1</ord>
<ord>2</ord>
<ord>3</ord>
</orders>
I could create two html Pages (customer report, order report). Using asp code, I can point my user to the correct page
VB Code:
<%@ Language=VBScript %>
<%
const CustRep = "customer"
const OrdRep = "order"
report = Request.Form("reportname")
if report = CustRep then
Response.Redirect("http://myserver/customerReport.htm")
elseif report = OrdRep then
Response.Redirect("http://myserver/orderReport.htm")
else
Response.Redirect("http://myserver/notRecognised.htm")
end if
%>
In the customer report page, you would create a data island and bind a table or other controls to this dso. You can find more about data islands and data binding in the msxml4 sdk, available for download from microsoft
Code:
<html>
<head></head>
<body>
<object width="0" height="0" classid="clsid:550dda30-0541-11d2-9ca9-0060b0ec3d39" id="xmldso">
</object>
<script language="javascript">
var doc = xmldso.XMLDocument;
doc.load("myxmlfile.xml"); //load data
</script>
<table src="#xmldso">
<tr>
<td><span datafld="cust"></span></td>
</tr>
</table>
</body>
</html>
This should display all the values within the cust elements. This type of table is called a repeating table and these are very handy.
Another method of achieving what you are trying to do, is to use xslt's. These format xml documents into any other form you choose. Try my method above first. Once you have that right, we can move onto the xslt method.
-
Jul 8th, 2002, 07:24 AM
#3
Thread Starter
Member
Wow....thanks for the tutorial 
Although the method you explain here is helpful, it's not quite what i had in mind.
The data that i store in the xml file is not actually data that i want to display but rather what I want to use as parameters to create the reports ( table headers, sql query, colours, other formating info). We want to store this information in a local xml file that we can query. Once we have this info we pass it to the reporting engine that we have which uses the info to query the DB and format the resulting data.
We want the local xml file so that we can create dev enviroments where we can play around with new reports without drawing the report structure and format from our central DB. The file could actually be in any format but i figured since xml is the language for defining data, it would be a good way to go.
Would you recommend doing this in any other way ?
Thanks
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|