Jump to content

How To Embed Xml Data Inside An Html Page But Not Parse The Xml Data At Load Time ?


tdao
 Share

Recommended Posts

hi, is there a way that I can tell the browser not to parse the xml data when the xml data is embed internally?I need to embed some xml data into an html report to be used with AJAX. However, the xml data is so big that it really slows down the loading time. I could make the xml data external but that will require me to send the report to my clients in 2 separate files (html and xml). I would prefer putting everything in one file but then I'll have the loading problem. I try to use the option display=none but that didn't help either.Anyone had experience with this, please shred some light. Thanks a lot.TD.

Edited by tdao
Link to comment
Share on other sites

Sounds like my current project.Could you use the httpRequest object (AJAX) to request the file be sent in the background after page load? This assumes that you don't need it right away.Maybe I don't understand the question. Once your XML is loaded into RAM, turning it into an XML object takes fractions of milliseconds.The download itself is always the biggest time consumer. A big file will take time; it's just that simple. One thing you can do to shorten the time is to pare your XML down to the essentials. And that depends on your priorities. In a 100K file, a lot of space can be used by tabs and line breaks. Tag names also take up space, especially when the actual content is pretty short. If you can shorten the tag names while still making them understandable to human readers, you might be better off. Depending on the content, you could shave 20K off a 100K file, improving performance by 20%, without losing anything significant. Your server could help with this process too, removing white space and changing tag names before forwarding the file. This way, anyone who needs to look at the original can view it in its most user-friendly form, and you get the benefit of cutting transmission time.After that, the big time-eater is writing to your display, especially if you're creating hundreds of DOM objects and setting their properties on the fly. This depends on the system and browser, of course. A Duo running at 2.4GHz or better can be pretty snappy. Slower machines, not so much.

Link to comment
Share on other sites

well, the project i'm working on is a bit different. It is actually a windows application used to display xml data. There is no server involved. So for the computers that are installed with this application, they can view our xml data. For the computers that don't have our application, we need to export everything (xml, xslt, javascript, css, etc.) into one single html file and send it to our customers to view locally with some browser.This process has been working fine for awhile until recently when we have a huge xml data (around 50MB). Any computer will hang or take minutes to load the html file. So our solution is to use AJAX to load the xml data piecewise to a table based on the scrolling event. This works fine if we split the largest table in the xml file to a separate file and reference to it using <xml id="someID" src="somefile"/>. However, our goal is to put everything into a single html file so that our customers who don't have access to our server or our application can still view the report with some browser....but then, doing this will bring us back to the loading problem. It takes too long to load the html file even though I already set display=none like this <xml id="someID" display="none">...content...</xml>. Looks like the browser (both IE and Firefox) tries to load everything as long as the resource stays within the file. If the resource is referenced from a separate file, the browser won't do anything until we tell it to. So what I really want to achieve here is to embed all of the xml data within the html file as a dummy resource and make sure the browser will not do anything to it at load time until I tell it to so that the loading time is optimized...thanks for any helps on this matter!Tung.

Edited by tdao
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...