0
<tr valign="middle">
   <td class="marginTd" width="25" align="right">
   <a class="actionbtn" onclick="addFavourite();" href="#" data-hasqtip="1" oldtitle="Add   Record to Favourites" title="" aria-describedby="qtip-1">
   </td>

   <td class="marginTd" width="25" align="right">
   <a class="actionbtn" onclick="copyLink();" href="#" data-hasqtip="2" oldtitle="Copy Document Link URL" title="`enter code here`" aria-describedby="qtip-2">
   </td>

   <td class="marginTd" width="25" align="right">
   <a class="actionbtn" onclick="gotoEmailRecord();" href="#" data-hasqtip="3" oldtitle="Email Record" title="" aria-describedby="qtip-3">
   </td>

   <td class="marginTd" width="25" align="right">
   <a class="actionbtn" onclick="gotoMrkForDel();" href="#" data-hasqtip="4" oldtitle="Mark for Delete" title="">
   </td>

   <td class="marginTd" width="25" align="right">
   <a class="actionbtn" target="mainFrame" onclick="gotoViewCopy();" href="#" data-hasqtip="5" oldtitle="Open Document" title="">
   </td>

   <td class="marginTd" width="25" align="right">
   <a class="actionbtn" onclick="gotoGetCopy();" href="#" data-hasqtip="6" oldtitle="Get Copy" title="">
   </td>

   <td class="marginTd" width="25" align="right">
   <a id="idIconEditLn" class="actionbtn" onclick="gotoUpdate();" href="#" data-hasqtip="7" oldtitle="Edit" title="">
   </td>

   <td class="marginTd" width="25" align="right">
   <a id="idIconEditLn" class="actionbtn" onclick="lock();" href="#" data-hasqtip="8" oldtitle="Lock only" title="">
   </td>
</tr>

pardon me for my long xml file. i would like to get the integer value (1, 2, 3, 4, 5, 6, 7, 8) i have tried .//*[@class='actionbtn'].getAttribute('data-hasqtip') and .//*[@class='idIconEditLn'].getAttribute('data-hasqtip') but it isn't working. may i know is there any xpath can solve this problem can return me only the numbers? (1, 2, 3, 4, 5, 6, 7, 8)

Passerby
  • 9,715
  • 2
  • 33
  • 50
sssheng
  • 47
  • 1
  • 8

1 Answers1

1

First, your XML is malformed. The tags must be closed.

After you fix that, this will work //@data-hasqtip

Ryan Cromwell
  • 2,613
  • 1
  • 17
  • 33
  • thanks for sharing. i have test out the xpath you suggested it return me the whole length [data-hasqtip="1"] iszit possible to let it return only the number? – sssheng Jan 17 '14 at 03:46
  • I imagine you're running into a library issue. What are you using? Often libraries will return something akin to a `Node` or `XNode` instance. That node will have a `value` property. – Ryan Cromwell Jan 17 '14 at 03:51
  • oh, im doing some web automation. im using selenium and java to do it. – sssheng Jan 17 '14 at 03:59
  • Take a look at http://stackoverflow.com/a/2818246/54996. Assuming you're using that library, it does in fact have a `getNodeValue()` method. – Ryan Cromwell Jan 17 '14 at 04:10
  • yeap i saw that getNodeValue method.. what does it return? – sssheng Jan 17 '14 at 06:05
  • 1
    You can directly use `//@data-hasqtip`, there is no difference to your query as attributes can only exist as direct children of element nodes. – Jens Erat Jan 17 '14 at 19:18
  • @sssheng give it a whirl. as i mentioned, each library will be different, but i suspect it will provide a string variant of your attribute value. – Ryan Cromwell Jan 19 '14 at 00:02