As the writer of the answer being discussed, I wanted to come here and explain what I did and why... not only to DebajanB but to other readers. Feel free to give me feedback in the comments if you feel that I did something "wrong" or could improve my answer in approach (or even answer content).
I originally downvoted DebanjanB's answer because it gave misleading information and explained why I downvoted in my comment. After a few hours had passed... the answer wasn't corrected, OP asked me for more details on my comment, DebanjanB updated his answer but OP responded that it still didn't work. (I'm not sure why the OP accepted his answer if it didn't work but I chalked it up to OP being new to the site.)
At this point, there were no other answers and in order to answer OP's question to me, I couldn't have explained in any detail in the comments so I wrote my own answer. I started my answer by giving the most straightforward answer, which was basically a small adaptation of OP's attempt. I then explained how I approach problems like this and during that explanation, I expanded on my comment as to why XPath is not a good solution in general (with references) and why it's especially error-prone in this particular situation. I referenced DebanjanB's specific XPath and explained why it was the less optimal solution. My intention was not to attack him personally but just to reference his answer (and I think I succeeded or did I?).