Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The short answer is "no". </p> <p>XPath is a method for selecting elements in a DOM. It can also be used to read attributes and calculate values, but it can't be used to modify the DOM. You might be getting confused with XSLT, which uses XPath expressions to select elements and can return a modified document. You could use a generic XML document, then use different XSL style sheets using XSLT to generate different documents in various languages, say HTML, XML, postscript, and so on.</p> <p>In any case, why would you bother with XPath in this case? There is a <em>document.links</em> collection that requires simple property access, no function calls or evaluating XPath expressoins. You can change simple text content by assigning to the W3C <a href="http://www.w3.org/TR/DOM-Level-3-Core/core.html#Node3-textContent" rel="nofollow">textContent</a> or proprietary MS <a href="http://msdn.microsoft.com/en-us/library/ms533899%28v=VS.85%29.aspx" rel="nofollow">innerText</a> property (again, simple property access rather than function calls):</p> <pre><code>function modLinks() { var links = document.links; var i = links.length; while (i--) { setText(links[i], 'Visit ' + getText(links[i]) ); } } // Simple helper functions, can be made faster and more robust // but sufficient for an example. function getText(el) { if (typeof el.textContent == 'string') { return el.textContent; } else if (typeof el.innerText == 'string') { return el.innerText; } } function setText(el, text) { if (typeof el.textContent == 'string') { el.textContent = text; } else if (typeof el.innerText == 'string') { el.innerText = text; } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload