Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 430
  • Last Modified:

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.

  • 2
1 Solution
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.

<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

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)

oXML.save Response

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.


Brandon Driesen
slight typo in the global.asa code
<object id="oPersist" progid="Msxml2.FreeThreadedDOMDocument.4.0"
<script language="VBScript">
Sub Application_OnStart()
oPersist.async = False
oPersist.load Server.MapPath("xml/data.xml")
End Sub

Sub Application_OnEnd()

End Sub

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now