Я пытаюсь пройти через эту строку кодов через xpath javascript, но я не могу получить значение первого тега li, который является Thesis [Master's) - University, 2012. ":
<table id="addInformationGraphics" cellpadding="2" cellspacing="0" width="100%">
<TR><td background="/images/icons/general/thickline.gif" nowrap vAlign='top'>
<span class='ColRow'> </span><span class="SectionHeader" ><a name = 'anchorAdditionalInfo'></a>
Additional Info
</span>
</td>
<A name="AdditionalInfo"></A></TR></TABLE>
<table id="addInformation" cellpadding="2" cellspacing="0"><tr>
<td vAlign="top"><IMG SRC="/images/icons/general/spacer.gif" width="20" height="1"></td>
<td class="ColRow"><ul><li>
Thesis [Master's) -- University, 2012.</li></ul>
</td>
</tr>
Вот один из тех, которые я пробую:
var getaddInformation = document.evaluate("table[contains(@id,'addInformation')]/tbody/tr/td/following- sibling::td/ul/li", document, null, XPathResult.ANY_UNORDERED_NODE_TYPE, null );
if (getaddInformation.singleNodeValue) {
var addInformationDetails = getaddInformation.singleNodeValue.textContent;
}
console.log(addInformationDetails);
var getaddInformation = document.evaluate("table[contains(@id,'addInformationGraphics')]/following-sibling::table/td/following-sibling::td/ul/li", document, null, XPathResult.ANY_UNORDERED_NODE_TYPE, null );
if (getaddInformation.singleNodeValue) {
var addInformationDetails = getaddInformation.singleNodeValue.textContent;
}
console.log(addInformationDetails);
И еще один:
var getaddInformation = document.evaluate("table[contains(@id,'addInformationGraphics')]/following-sibling::table/td/following-sibling::td/ul/li", document, null, XPathResult.ANY_UNORDERED_NODE_TYPE, null );
if (getaddInformation.singleNodeValue) {
var addInformationDetails = getaddInformation.singleNodeValue.textContent;
}
console.log(addInformationDetails);
Для простоты, вот xpath:
"table[contains(@id,'addInformation')]/tbody/tr/td/following-sibling::td/ul/li
And the other one:
table[contains(@id,'addInformationGraphics')]/following-sibling::table/td/following-sibling::td/ul/li
Что может быть мне не хватает, если я не ошибаюсь, иерархия документа HTML выглядит примерно так:
table
tbody
tr
td
td
ul
li
Заранее спасибо!