hi Sunny,
Thanks for the response. Check the following code and see what am i missing
here?
private void button1_Click(object sender, System.EventArgs e)
{
HTMLDocument htmlDoc = new HTMLDocumentClass();
IHTMLDocument2 doc = (IHTMLDocument2)htmlDoc;
try
{
object[] oResponseHTML= (object[])getHtml();
MessageBox.Show(oResponseHTML.ToString());
doc.write(oResponseHTML);
if (null != doc)
{
MessageBox.Show(htmlDoc.all.length.ToString()+"\n"+doc.all.length.ToString()
);
}
richTextBox1.Text = "";
for(int i=0; i<doc.all.length;i++)
{
richTextBox1.Text = richTextBox1.Text + doc.all.item(null,i);
}
//richTextBox1.Text= htmlDoc.toString();
}
catch(Exception ex)
{
MessageBox.Show(ex.Message + "\n"+ex.StackTrace);
}
}
private object[] getHtml()
{
object[] strHTML=null;
XMLHTTP30Class xmlDoc = new XMLHTTP30Class();
xmlDoc.open("POST","
http://www.google.com",false,"","");
xmlDoc.send(null);
if (xmlDoc.statusText.ToUpper() == "OK")
strHTML = (object[])xmlDoc.responseStream;
xmlDoc=null;
return strHTML;
}
Can you please correct this code?
Thanks
Atul
Sunny said:
Hi Atul,
I'm using this:
object[] oPageText = {sWebPage};
myDoc = new HTMLDocumentClass();
IHTMLDocument2 oMyDoc = (IHTMLDocument2)myDoc;
oMyDoc.write(oPageText);
This works fine. Of course you have to put this in try/catch block in
order the page is not well formated.
Hope that helps
Sunny
Hi,
I did the way you just told. Let me clear about the problem.
I am having one HTML text stored in a string say "strResponseHTML" variable.
The code which I am trying to use is as follows:
private void button1_Click(object sender, System.EventArgs e)
{
HTMLDocument htmlDoc = new HTMLDocumentClass();
IHTMLDocument2 doc = (IHTMLDocument2)new HTMLDocumentClass();
try
{
string strResponse = getHtml();
htmlDoc.write(strResponse);
if (null != htmlDoc)
{
MessageBox.Show(htmlDoc.all.length.ToString());
}
richTextBox1.Text= htmlDoc.toString();
}
catch(Exception ex)
{
MessageBox.Show(ex.Message + "\n"+ex.StackTrace);
}
}
Now upon seeing the code, what actually I am trying to do is that I want to
parse the response HTML to look for some objects with the values. Those
values I would like to compare.
We use MSXML2.dll to parse the XML document using XMLDOM, similary we "can"
use MSHTML.dll to parse the HTML document using htmlDocument object. But how
to load the strResponseHTML into HTMLDocument object, that I want to know.
If any body could help me out, highly appreaciated.
Thanks
Atul
scenario. I
am response
HTML.