Link to home
Start Free TrialLog in
Avatar of douglaskarr
douglaskarr

asked on

dhtml, xml, table sub table to xml query... I think...

I've got a 10Mb+ XML table.  For ease, let's say that the table has year, make, and model of cars.

I'd like to show the table with year only.  If the user clicks on the year, I'd like it to go back and query the parent xml and return all the makes of the cars.  If the user clicks on the make of the car, I'd like it to go back and query the xml by year and make and return all the model cars.

It's important that the entire XML doc is not loaded... it's too big.  Basically, user interaction queries and returns data.

Thanks,
Doug
Avatar of AlfaNoMore
AlfaNoMore

What are you going to use to parse the XML? And will this be client-side or server-side (in which case, what programming language will you use?)

If you do this Server-side using Microsoft's XML 3.0 Parser, and VBscript as your ASP language, then it can be done, but the server will still need to load the XML doc before ot can parse/ translate it.

Is there any other way to break the file into smaller ones?
If the size is an issue,
1. Store the data inside a database e.g. Access, MySQL, SQL Server, Oracle for example.
2. Use SQL Queries to retrieve the data into a recordset.
3. With ADO 2.5+, Save the recordset into an XML Object.
oRS.Save oXML
4. Do your transforms then.

Do not misuse XML. It is good as a delivery system but is not good as a storage system. Databases are good for that especially large amounts of data.

10 Mbs of data would roughly translate to 30 to 50 MBs of RAM taken just to load the entire tree into memory. If this operation is performed using a FreeThreadedDOMDocument, then the initial loading would take some time (relative) and only at point of loading.

e.g.
global.asa
===========
<object id="oPersist" progid="Msxml2.FreeThreadedDOMDocument.4.0" runat="server">
<script language="VBScript">
Sub Application_OnStart()
oPersist.async = False
oPersist.load Server.MapPath("xml/data.xml")
End Sub

Sub Application_OnEnd()

End Sub
</script>


page.asp
========
<%@language="VBScript"%>
<%
Response.ContentType = "text/xml"
Response.Expires = -1
Response.CacheControl = "no-cache"
Response.AddHeader "Pragma","no-cache"

Dim oXML, oMain, oNodeList, oNode
Dim szMake, szYear, szXPath
szMake = Response.QueryString("make")
szYear = Response.QueryString("year")
szXPath = "//cars[@make = '" & szMake & "' and @year = " & szYear & "]"
Set oMain = Application.StaticObjects("oPersist")
Set oXML = Server.CreateObject("Msxml2.FreeThreadedDOMDocument.4.0")
oXML.async = False
oXML.appendChild oXML.createProcessingInstruction("xml","version='1.0' encoding='iso-8859-1")
oXML.appendChild oXML.createElement("root")
Set oNodeList = oMain.selectNodes(szXPath)
For Each oNode in oNodeList
 oXML.documentElement.appendChild oNode.cloneNode(True)
Next

oXML.save Response
%>

Notes
=====
1. What this does is to access the FreeThreaded DOM Document.
2. Get The XPath Statement
3. Append the found nodes to another XML Tree (thereby reducing the amount of data to be sent to the client)
4. Saving the XML as a Stream to the Response Object which implements the IStream Interface.

Regards,

Brandon Driesen
ASKER CERTIFIED SOLUTION
Avatar of b1xml2
b1xml2
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial