473,394 Members | 1,785 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

C# mshtml createDocumentFromUrl not returning expected results

I am trying to use mshtml to parse a web page without using IE.
I create the HTMLDocument object, and then assign to it the output value from createDocumentFromUrl().
I know that this is at least partially working, because I am able to access the HTMLDocument.title.

However, when I try to read the output of the getElementsByTagName() member, I am getting length = 0 inside the IHTMLElementCollection object receiving the output.

When I take an IE.Document, I am able to see the expected output from getElementsByTagName().

What am I doing wrong? I have been googling, and don't know what else to try.
Thanks in advance for any help or suggestions.

Here is the snippet: (I have tried different URLs that I would expect to see some <DIV> tags...

string requestURL = "http://www.google.com";
HTMLDocument ProfileHTML = new HTMLDocument();
IHTMLDocument2 ProfileHTML2;
((IHTMLDocument2)ProfileHTML).write("<html></html>");
((IHTMLDocument2)ProfileHTML).close();
ProfileHTML2 = ((IHTMLDocument4)ProfileHTML).createDocumentFromUr l(requestURL, "null");
while(ProfileHTML2.readyState != "complete")
{
Thread.Sleep(0);
}
mshtml.IHTMLElement2 body2 = (mshtml.IHTMLElement2) ProfileHTML2.body;
mshtml.IHTMLElementCollection objDivColl;
objDivColl = ((IHTMLDocument3)ProfileHTML).getElementsByTagName ("DIV");
Nov 30 '06 #1
0 3340

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Mat | last post by:
Hi all. I need to build a little HTML parser. I made 2 versions, for console e for window. In console mode it seems to work (but not always, sometimes it doesn't parse the HTML file), in window...
1
by: NG | last post by:
Hi All, I had posted this question earlier but I could not find a solution to my problem hence reframing my question. GOAL: I want to use the MSHTML to access a HTML page, access the DOM...
2
by: DotNetShadow | last post by:
Hi Guys, I have been reading heaps of information in regards to MSHTML object being used in .NET applications, windows and UI-less. I have read the walkall samples and tried various techniques...
4
by: Lars-Erik Aabech | last post by:
Hi! I've been walking in extacy since reading the article about test automation with IE in the latest MSDN mag. (http://msdn.microsoft.com/msdnmag/issues/05/10/TestRun/default.aspx) After a...
3
by: DotNetShadow | last post by:
Hi Guys, I have been reading heaps of information in regards to MSHTML object being used in .NET applications, windows and UI-less. I have read the walkall samples and tried various techniques...
3
by: ddd | last post by:
I am trying to use MSHTML without the webbrowser and I am having a few problems. Right now all I am trying to do is load an URL(html page) and access its innerhtml. What I have is: Dim doc As...
14
by: Vibhu Bansal | last post by:
Hello, I am having certain problems in trying to use the function createDocumentFromUrl in VB.NET but get this error.."Object reference not set to an instance of object". Here is the code that I...
0
by: b4silence | last post by:
Hello all, I'm trying to handle an html document using the mshtml library but with the following code: ... using mshtml;
0
by: timeline | last post by:
VB-WEB: proint Job Name is about:blank followed by content to print C#-APP: Sending a Job to the Printer with Crystal Reports I am using mshtml.HTMLDocumentClass docObject=new...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.