2

First time using HtmlAgilityPack, i'm retrieving nodes inside an html that has 2 different elements, sharing a value as id for one and as name for the other:

    <span name="abc"></span>
     . . .
    <div id="abc"></div>

When i use GetElementById("abc") i end up getting the element whose name, and not the id, is the one specified. Hows so?

Thanks in advance

strongmmc
  • 137
  • 12
  • http://www.456bereastreet.com/archive/200802/beware_of_id_and_name_attribute_mixups_when_using_getelementbyid_in_internet_explorer/ - very good to know! I have learnt it just now, thanks – koksalb Mar 22 '17 at 08:54
  • @koksalb htmlAgilityPack is a C# library for html manipulation. It shouldn't have anything to do with how Internet Explorer handles names. – Nzall Mar 22 '17 at 08:56
  • 2
    There is an Explanation: [http://stackoverflow.com/questions/13300698/document-getelementbyid-returns-element-with-name-equal-to-id-specified](http://stackoverflow.com/questions/13300698/document-getelementbyid-returns-element-with-name-equal-to-id-specified) – Evya2005 Mar 22 '17 at 08:58
  • @andy can't for policy reasons. assuming that those elements are inside a body tag is enough. – strongmmc Mar 22 '17 at 11:26

1 Answers1

0

It seems like I can't reproduce your issue in VB.NET (see above screenshot).

It's only targetting the element whith id "abc" and not the one with same name.

Maybe you could send us a piece of code with wrong behaviour ?

Working piece of code

chateaur
  • 346
  • 1
  • 13