我有一个带有这个元的pagehtml
<meta name="known" content="xxx">
<meta name="city" content="xxx">
并使用此代码返回元
HtmlDocument domDocument = webBrowser1.Document;
HtmlElementCollection metaElements = domDocument.GetElementsByTagName ("meta"); // get all the meta elements
foreach (HtmlElement meta in metaElements)
{
string name = meta.GetAttribute("name");
string content = meta.GetAttribute("content");
// get more attributes if needed, then make it do something useful.
// for lack of a better idea...
MessageBox.Show(name + content);
}
但返回所有元前:“城市xxx”,新消息框“知道xxx”等......我只需要城市的元内容,这可能吗?