To access an element i used the following command document.getElementById('ghi').innerHTML="Replace the paragragh with this text"
How to use the same functionality in javascript by using xpath As in out suite we used xpath only
Asked
Active
Viewed 2,135 times
0

A Paul
- 8,113
- 3
- 31
- 61

Harish Naidu
- 35
- 1
- 12
-
https://developer.mozilla.org/en/docs/Introduction_to_using_XPath_in_JavaScript – SivaRajini Feb 04 '14 at 12:16
-
http://stackoverflow.com/a/32623171/502860 – iimos Sep 17 '15 at 05:33
1 Answers
1
It would do what you want:
function xpathFindById(id) {
return document.evaluate(".//*[@id='" + id + "']", document.lastChild, null,
XPathResult.ANY_TYPE, null).iterateNext();
}
var content = xpathFindById("content");

Mehran Hatami
- 12,723
- 6
- 28
- 35