开发者

Why do these two nodes not compare equal?

I've got some HTML:

<html>
<head>
    <title>title</title>
</head>
开发者_JAVA百科<body>
    <p>a pargraph</p>
</body>
</html>

For which I grab the body and p node, and then I tried

Console.WriteLine(p.ParentNode == body);

And it's telling me False. Why is that? I need this functionality in my program...


That's because the equality operator is not overridden! Try using

p.ParentNode.XPath == body.XPath

instead!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜