开发者

Why do these two nodes not compare equal?

开发者 https://www.devze.com 2023-01-19 01:31 出处:网络
I\'ve got some HTML: <html> <head> <title>title</title> </head> 开发者_JAVA百科<body>

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

精彩评论

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

关注公众号