I have the following table data to traverse in my HTML:
<table id="publicationTable" cellpadding="2" cellspacing="0">
<tr>
<td vAlign="top"><IMG SRC="/images/icons/general/spacer.gif" width="20" height="1"></td>
<td class="SmallColHeading">Published </td>
<td class="ColRow">Publisher, place and date of publication</td>
</tr>
<tr>
<td vAlign="top"><IMG SRC="/images/icons/general/spacer.gif" width="20" height="1"></td>
<td class="SmallColHeading">
Format </td>
<td class="ColRow">
vii, 201 pages ; 23 cm. </td>
</tr>
I want to output the text "vii, 201 pages ; 23. cm." with document.evaluate but I am missing something. The thing is that the selector should be td with class attribute value "SmallColHeading" and that has (contains) a text node/value of Format.
var Pagination = document.evaluate("//td[contains(., 'Format')]", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null );
var Pagination2 = Pagination.nextSibling.innerHTML;
if (Pagination.singleNodeValue) {
var Pages = Pagination.singleNodeValue.textContent;
}
alert(Pagination2);
alert(Pages);
I'm trying various combinations specially after nextSibling like removing innerHTML (I'm getting undefined) or replacing it with textContent (I'm getting Cannot read property 'textContent'). I'm struggling with traversing nextSibling through javascript on this HTML since tr does not even have an id value and this all what we have we have in the system. Thanks in advance!