473,386 Members | 1,810 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,386 software developers and data experts.

MSHTML...

Mat
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 mode (target winexe) I get no result...
This is my code:

=== CODE ===
using MSHTML;
using System;
using System.Drawing;
using System.Windows.Forms;

public class HTMLParser : Form
{
[STAThread] public static int Main( string[] args )
{
Application.Run( new HTMLParser() );
return 0;
}

public HTMLParser()
{
this.Text = "HTML Parser";
this.StartPosition = FormStartPosition.Manual;
this.Location = new Point( 100, 100 );
this.Size = new Size( 200, 200 );

Button button = new Button();
button.Text = "Parse";
button.Location = new Point( 10, 80 );
button.Size = new Size( 80, 25 );

button.Click += new System.EventHandler( ButtonClick );
this.Controls.Add( button );
}

private void ButtonClick( object sender, EventArgs evArgs )
{
try
{
HTMLDocument document = new HTMLDocument();
IHTMLDocument2 iDocument2;

( (IHTMLDocument2)document ).write( "<html></html>" );
( (IHTMLDocument2)document ).close();

iDocument2 = ( (IHTMLDocument4)document ).createDocumentFromUrl(
"file:///" + System.Environment.CurrentDirectory + "\\myDoc.html", "null" );

IHTMLElementCollection elemColl = (IHTMLElementCollection)
iDocument2.all;
foreach( IHTMLElement elem in elemColl )
MessageBox.Show( elem.tagName );
}
catch( Exception e )
{
MessageBox.Show( e.ToString() );
}
}
}
======

Someone can hel me?
I tried also to use UCOMIPersistFile and Load function... same results.

Byez, -Mat-
Nov 15 '05 #1
2 2128
Mat,

Does it work when you debug it, and not work when you don't debug it? I
have a feeling that because you are not waiting for the parsing to complete
it might be bombing. Try placing a try/catch block around your code in the
event handler for the button click, and see if an exception is thrown.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- ni**************@exisconsulting.com

"Mat" <in*******@privato.it> wrote in message
news:S5*********************@news2.tin.it...
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 mode (target winexe) I get no result...
This is my code:

=== CODE ===
using MSHTML;
using System;
using System.Drawing;
using System.Windows.Forms;

public class HTMLParser : Form
{
[STAThread] public static int Main( string[] args )
{
Application.Run( new HTMLParser() );
return 0;
}

public HTMLParser()
{
this.Text = "HTML Parser";
this.StartPosition = FormStartPosition.Manual;
this.Location = new Point( 100, 100 );
this.Size = new Size( 200, 200 );

Button button = new Button();
button.Text = "Parse";
button.Location = new Point( 10, 80 );
button.Size = new Size( 80, 25 );

button.Click += new System.EventHandler( ButtonClick );
this.Controls.Add( button );
}

private void ButtonClick( object sender, EventArgs evArgs )
{
try
{
HTMLDocument document = new HTMLDocument();
IHTMLDocument2 iDocument2;

( (IHTMLDocument2)document ).write( "<html></html>" );
( (IHTMLDocument2)document ).close();

iDocument2 = ( (IHTMLDocument4)document ).createDocumentFromUrl(
"file:///" + System.Environment.CurrentDirectory + "\\myDoc.html", "null" );
IHTMLElementCollection elemColl = (IHTMLElementCollection)
iDocument2.all;
foreach( IHTMLElement elem in elemColl )
MessageBox.Show( elem.tagName );
}
catch( Exception e )
{
MessageBox.Show( e.ToString() );
}
}
}
======

Someone can hel me?
I tried also to use UCOMIPersistFile and Load function... same results.

Byez, -Mat-

Nov 15 '05 #2
Mat
> Does it work when you debug it, and not work when you don't debug it?
I
have a feeling that because you are not waiting for the parsing to complete it might be bombing. Try placing a try/catch block around your code in the event handler for the button click, and see if an exception is thrown.


I don't use Visual Studio .NET so I can't use the Visual Debugger.
I don't know how does the cordbg work...

Uhm... the code of my event handler is inside a try/catch block
Another thing, if an exception is thrown the program execution is usually
interrupted...
Nov 15 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Dean Hallman | last post by:
I need to ensure client machine has Microsoft.mshtml installed in the GAC. And if not, deploy it. My app is a Browser Helper Object and depends on mshtml. Initially, I thought I could take care...
4
by: David Pendrey | last post by:
Hello all, I am using the WebBrowser control to browse a webpage containing frames and am having difficulties accessing the 'frames' property of a document object. Bellow is my code and the error...
10
by: Hans Merkl | last post by:
Hi, I have written an pap with .NET 2.0 and c# that uses MSHTML. It works fine on my development machine but on machines I deploy it to I get the following exception when ever I call MSHTML. ...
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...
5
by: Atara | last post by:
I am trying to convert the following code to VB .Net, I still have some gaps (the lines that are marked with (*)) and also I need an ending condition for the while loop. any help would be...
0
by: Atara | last post by:
Our application was build with VS 2003. I have tried to run it on a computer with .Net 2.0 (but without .Net 1.1 , as it should be used) and I got the following error - ...
11
by: Lucky | last post by:
hi guys, i need to parse html data that i've got from "Inet" object in vb6. now i want to prase the html data. here i got 2 options. one is MSXML and other is MSHTML. i tried both of them but i...
5
by: Jason | last post by:
Hi, I'm developing an HTML Editor Control using VB.Net 2003 for an application that used to use the DHTML Editor Control that is no longer supported. Well, it's been fun but I've hit a wall with...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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...

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.