0

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

A Paul
  • 8,113
  • 3
  • 31
  • 61
Harish Naidu
  • 35
  • 1
  • 12

1 Answers1

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