想要使用msHTML.HTMLDocumentClass [英] Want to use msHTML.HTMLDocumentClass

查看:114
本文介绍了想要使用msHTML.HTMLDocumentClass的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我刚刚进入C#。我面临一个问题。这是场景。我将一些数据发布到一个网站(https网站)。

。它返回我的回复HTML。

我想解析这个HTML并想要寻找一些特定的标签。为了实现相同的
,我想使用MSHTMLs HTMLDocumentClass接口。我不知道如何在C#中使用它。

我正在使用.NET framework 1.1。

对于发布数据,我正在使用XMLHTTP课程。


非常感谢任何帮助。


谢谢

Atul

Hi,
I just stepped into C#. I am facing one problem. Here is the scenario. I am
posting some data to one website (https site). It returns me response HTML.
I want to parse this HTML and want to look for some specific tags. To
achieve the same, I wanted to use MSHTMLs HTMLDocumentClass Interface. I
dont know how to use it in C#.
I am using .NET framework 1.1.
For posting the data, I am using XMLHTTP class.

Any help is highly appreciated.

Thanks
Atul

推荐答案

Dnia 2003-11-13 12:53,U?ytkownik Atul napisa3:
Dnia 2003-11-13 12:53, U?ytkownik Atul napisa3:

我只是进入C#。我面临一个问题。这是场景。我将一些数据发布到一个网站(https网站)。它返回我的响应HTML。
我想解析这个HTML并想要寻找一些特定的标签。为了实现相同,我想使用MSHTMLs HTMLDocumentClass接口。我不知道如何在C#中使用它。
我使用的是.NET framework 1.1。
对于发布数据,我使用的是XMLHTTP类。

任意非常感谢帮助。

感谢
Atul
Hi,
I just stepped into C#. I am facing one problem. Here is the scenario. I am
posting some data to one website (https site). It returns me response HTML.
I want to parse this HTML and want to look for some specific tags. To
achieve the same, I wanted to use MSHTMLs HTMLDocumentClass Interface. I
dont know how to use it in C#.
I am using .NET framework 1.1.
For posting the data, I am using XMLHTTP class.

Any help is highly appreciated.

Thanks
Atul






第一你应该为你的项目添加refernece - Microsoft.mshtml,

然后按名称空间mshtml你将有权访问HTMLDocumentClass


MS


Hi,

First you should add refernece to your project - Microsoft.mshtml,
then by namespace "mshtml" you will have access HTMLDocumentClass

M.S




我做了你告诉我的方式。让我清楚一下这个问题。

我有一个HTML文本存储在一个字符串中说strResponseHTML"变量。

我尝试使用的代码如下:


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(例外情况)

{

MessageBox.Show(ex.Message +" \ n" + ex.StackTrace);

}

}


现在看到代码后,实际上我想要做的是我想要
解析响应HTML以查找带有值的一些对象。我想要比较的那些

值。

我们使用MSXML2.dll使用XMLDOM解析XML文档,类似我们可以

使用MSHTML.dll使用htmlDocument对象解析HTML文档。但是如何将strResponseHTML加载到HTMLDocument对象中,我想知道。

如果有任何机构可以帮助我,那么高度相关。

谢谢

Atul


"MarcinSmó3ka" <泽*** @ eti.pg.gda.pl>在留言中写道

news:eo ************** @ TK2MSFTNGP09.phx.gbl ...
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

"Marcin Smó3ka" <ze***@eti.pg.gda.pl> wrote in message
news:eo**************@TK2MSFTNGP09.phx.gbl...
Dnia 2003-11- 13 12:53,U?ytkownik Atul napisa3:
Dnia 2003-11-13 12:53, U?ytkownik Atul napisa3:

我刚刚进入C#。我面临一个问题。这是场景。我想把一些数据发布到一个网站(https网站)。它返回我的回复
HTML。我想解析这个HTML,并希望寻找一些特定的标签。为了实现相同,我想使用MSHTMLs HTMLDocumentClass接口。我不知道如何在C#中使用它。
我使用的是.NET framework 1.1。
对于发布数据,我使用的是XMLHTTP类。

任意帮助非常感谢。

感谢
Atul
Hi,
I just stepped into C#. I am facing one problem. Here is the scenario. I am posting some data to one website (https site). It returns me response HTML. I want to parse this HTML and want to look for some specific tags. To
achieve the same, I wanted to use MSHTMLs HTMLDocumentClass Interface. I
dont know how to use it in C#.
I am using .NET framework 1.1.
For posting the data, I am using XMLHTTP class.

Any help is highly appreciated.

Thanks
Atul


您好,

首先,您应该为您的项目添加参考 - Microsoft.mshtml,
然后是名称空间mshtml你将有权访问HTMLDocumentClass

MS


Hi,

First you should add refernece to your project - Microsoft.mshtml,
then by namespace "mshtml" you will have access HTMLDocumentClass

M.S



Atul,


为了这样做,你将不得不使用HTMLDocument实现的IPersist接口之一

。您可以使用IPersistFile界面,

将字符串保存到文件然后以这种方式加载,或者您可以使用IPersistMemory接口使用

,将字符串放入非托管内存并且

然后将指针传递给内存中的该字符串。


但是,如果您在本文档中有相对URL,则需要

已经正确解决,那么这将无效。原因是

类不知道文件的来源,也无法解决这些问题。在这种情况下,您将不得不创建一个实现

的IMoniker(在System.Runtime.InteropServices

命名空间中表示,名称为UCOMIMoniker)。 />

当你创建这个实现时,你必须实现

BindToStorage方法,以便它返回一个IStream实现(

COM最终要求的界面)。这个IStream会将您返回到MSHTML的

字符串流式传输。


此外,您还需要实现
$的GetDisplayName方法b $ b UCOMIMoniker接口,以便它返回此字符串从下载的
的URL。


希望这会有所帮助。


-

- Nicholas Paldino [.NET / C#MVP]

- mv*@spam.guard.caspershouse.com


Atul < PY ***** @ hotmail.com>在消息中写道

news:uA ************** @ tk2msftngp13.phx.gbl ...
Atul,

In order to do this, you will have to use one of the IPersist interfaces
that HTMLDocument implements. You can use the IPersistFile interface,
saving your string to a file and then loading it that way, or you could use
the IPersistMemory interface, placing your string into unmanaged memory and
then passing the pointer to that string in memory.

However, if you have relative URLs in this document which you need to
have resolved correctly, then this will not work. The reason is that the
class doesn''t know about where the document came from, and can not resolve
these accordingly. In this case, you will have to create an implementation
of IMoniker (which is represented in the System.Runtime.InteropServices
namespace with a name of UCOMIMoniker).

When you create this implementation, you have to implement the
BindToStorage method so that it will return an IStream implementation (the
COM interface) which is asked for eventually. This IStream will stream the
string that you had back to MSHTML.

Also, you will want to implement the GetDisplayName method of the
UCOMIMoniker interface so that it returns the url that this string was
downloaded from.

Hope this helps.

--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Atul" <py*****@hotmail.com> wrote in message
news:uA**************@tk2msftngp13.phx.gbl...
我按照你刚刚说的方式做了。让我清楚这个问题。
我有一个HTML文本存储在一个字符串中说strResponseHTML
变量。我试图使用的代码如下:

private void button1_Click(object sender,System.EventArgs e)
HTMLDocument htmlDoc = new HTMLDocumentClass();
IHTMLDocument2 doc =(IHTMLDocument2)new HTMLDocumentClass();
尝试
字符串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);
}
}
现在看到代码后,我想要做的是我想要
解析响应HTML以查找带有值的一些对象。我想比较的那些值。
我们使用MSXML2.dll来解析使用XMLDOM的XML文档,类似于我们
can使用MSHTML.dll使用htmlDocument对象解析HTML文档。但是
如何将strResponseHTML加载到HTMLDocument对象中,我想知道。
如果有任何身体可以帮助我,高度相关。
谢谢
Atul
< br>"MarcinSmó3ka" <泽*** @ eti.pg.gda.pl>在消息中写道
新闻:eo ************** @ TK2MSFTNGP09.phx.gbl ...
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

"Marcin Smó3ka" <ze***@eti.pg.gda.pl> wrote in message
news:eo**************@TK2MSFTNGP09.phx.gbl...
Dnia 2003-11-13 12:53 ,U?ytkownik Atul napisa3:
Dnia 2003-11-13 12:53, U?ytkownik Atul napisa3:

我刚刚进入C#。我面临一个问题。这是场景。
Hi,
I just stepped into C#. I am facing one problem. Here is the scenario. I
am
将一些数据发布到一个网站(https网站)。它返回我的响应HTML。我想解析这个HTML,并希望寻找一些特定的标签。为了实现相同目的,我想使用MSHTMLs HTMLDocumentClass接口。
posting some data to one website (https site). It returns me response HTML. I want to parse this HTML and want to look for some specific tags. To
achieve the same, I wanted to use MSHTMLs HTMLDocumentClass Interface.



我不知道如何在C#中使用它。
我正在使用.NET framework 1.1。
对于发布数据,我使用的是XMLHTTP类。

非常感谢任何帮助。

谢谢 Atul


I dont know how to use it in C#.
I am using .NET framework 1.1.
For posting the data, I am using XMLHTTP class.

Any help is highly appreciated.

Thanks
Atul


您好,

首先,您应该将参考添加到您的项目 - Microsoft.mshtml,
然后通过名称空间mshtml你将有权访问HTMLDocumentClass

M.S


Hi,

First you should add refernece to your project - Microsoft.mshtml,
then by namespace "mshtml" you will have access HTMLDocumentClass

M.S




这篇关于想要使用msHTML.HTMLDocumentClass的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆