M
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-
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-