Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Render HTML from a string

Posted on 2002-07-27
5
Medium Priority
?
616 Views
Last Modified: 2010-04-15
I have a windows app that checks URL response time of our various web sites.  Right now it just checks the URL response time by using the HttpWebRequest class and downloading the sites html.  

I want to add an option to render the html that was downloaded.  When the page is rendered it would obviously download all the images of the site and timing that would also be useful.

When I am finished downloading all the html it is stored into a string.  How can I render the html in this string.  At this time I do not intend on giving the user the option of viewing the rendered page so if it doesnt render 100% correct like it would in Internet Explorer its not a show stopper.  I am mainly concerned about the amount of time to download all the content from the html (images, etc).

Thanks
Darrell
0
Comment
Question by:larockd
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 1

Accepted Solution

by:
sdn421 earned 400 total points
ID: 7185702
You could write the string to a file and then open the file.

using System;
using System.IO;

string fileName = "myFile.htm";          
FileInfo file = new FileInfo(@"C:\acc" + fileName);

StreamWriter sw = file.CreateText();    
sw.WriteLine(htmlString);              
sw.Close();

You could also use an IE control as an ActiveX component.
Add a reference to "Microsoft Web Browser" in your project. You can then use this object to navigate and display the web page.

I am not sure if this is what you are looking for.  Let me know if you need something else.

Good Luck.

0
 

Author Comment

by:larockd
ID: 7186821
Basically what I am looking for is a way to render the page in the background.  It does not matter if the user sees the rendered page.  The whole purpose for the rendered page is to time how long it takes to download the whole page.

For example if you have two pages and they each display one image and the one page's image is 5K and the other pages image is 5 megs then the time it takes to download each page's html will be close, but the amount of time to download the pages associated parts (images) will dramitically differ for both those pages.

I am interested in using the activeX web browser control how would you do that?

dl
0
 
LVL 14

Expert Comment

by:AvonWyss
ID: 7241536
With your approach, you will always have to wait until the page has finished loading until you know how long it takes. And the time you measure may be completely wrong in several situations: if the user is downloading something else from the net, or if the server or connection to it is unusually slow.

Therefore, what I would do to solve your task, is to parse that HTML file yourself, finding any IMG, LINK REL, EMBED, OBJECT etc. tags, then request these with a HEAD request (which will return the content size without actually downloading it). Add all the sizes together (plus some bytes for protocol overhead if you want accurate numbers) and divide it by the speed of the targeted connection (e.g. how fast would it be on a cable connection, or on a crappy old 28'800 modem?).
0
 

Author Comment

by:larockd
ID: 7243272
AvonWyss,

The reasons you site for the time being skewed is exactly what my program is attempting to monitor.  My program is not intended to give you an ideal response of a webpage load, but it is intended to alert you to problems such as poor connections, saturated paths, etc.  

Darrell
0
 
LVL 20

Expert Comment

by:TheAvenger
ID: 9506469
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:
Accept a comment by sdn421
Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

TheAvenger
EE Cleanup Volunteer
0

Featured Post

Tech or Treat! - Giveaway

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question