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
  • 7,797
  • 2
  • 27
  • 57
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,355
  • 6
  • 27
  • 35