示例HTML:
<html><body>
<form id="form1">
<input name="foo1" value="bar1" />
<!-- Other elements -->
</form>
<form id="form2">
<input name="foo2" value="bar2" />
<!-- Other elements -->
</form>
</body></html>
Run Code Online (Sandbox Code Playgroud)
测试代码:
HtmlDocument doc = new HtmlDocument();
doc.Load(@"D:\test.html");
foreach (HtmlNode node in doc.GetElementbyId("form2").SelectNodes(".//input"))
{
Console.WriteLine(node.Attributes["value"].Value);
}
Run Code Online (Sandbox Code Playgroud)
该声明doc.GetElementbyId("form2").SelectNodes(".//input")给了我一个空引用.
我做错了什么?谢谢.
我从某处读了以下代码:
template<class T> class A {
T a;
public:
A(T x):a(x) {}
operator T() const {return a;} // what is point here?
};
int _tmain(int argc, _TCHAR* argv[])
{
A<int> a = A<int>(5);
int n = a;
cout << n;
return 0;
}
Run Code Online (Sandbox Code Playgroud)
下线是什么意思?
运算符T()const {return a;}
例如:
template <typename T>
void foo(T ptr)
{
typedef GET_CLASS_TYPE(T) ClassT;
typedef GET_VALUE_TYPE(T) ValueT;
// ...
}
struct Bar
{
int var;
};
foo(&Bar::var);
Run Code Online (Sandbox Code Playgroud)
里面的最后一个函数调用foo(...),ClassT应该是Bar和ValueT应int.
如何使用普通C++(不能使用C++ 11功能)或者提升?