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

2

1 Answer 1

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");
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.