-3

I am trying to parse html. Two tables has the same id in the same html. How can I parse this?

<div>
      <table width='450' border=4  id='1234azert'>
      ...
      </table>
      <table width='450' border=5  id='1234azert'>
      ...
      </table>
</div>
Raul Rene
  • 10,014
  • 9
  • 53
  • 75
RockOnGom
  • 3,893
  • 6
  • 35
  • 53

3 Answers3

3

Yes you can. If you use HtmlAgilityPack you can use XPath and set index of element wich you are need.

alnasfire
  • 720
  • 6
  • 23
-1

The same ID can not be assigned to multiple elements. An ID is unique. A class however represents a group or collection and allows you to do what you want.

Karl Laurentius Roos
  • 4,360
  • 1
  • 33
  • 42
-2

It should never be the case. Two elements should never have the same id in any scenario. If you have such case, first element with that id in the dom tree is always returned.

More explanation here :

Is it normal to have two elements with same id in two div elements with other id?

Community
  • 1
  • 1
LPD
  • 2,833
  • 2
  • 29
  • 48