Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6801537
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T19:06:44+00:00 2026-05-26T19:06:44+00:00

var links = document.evaluate(//BODY/CENTER[1]/P[1]/TABLE[1]/TBODY[1]/TR[1], document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,null).evaluate(//A); basically I need to find an element

  • 0
var links = document.evaluate("//BODY/CENTER[1]/P[1]/TABLE[1]/TBODY[1]/TR[1]", document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,null).evaluate("//A");

basically I need to find an element via xpath. then search this element via xpath. The above doesn’t work obviously but neither does using contextNode argument.

var headings = document.evaluate("//BODY/CENTER[1]/P[1]/TABLE[1]/TBODY[1]/TR[1]", document, null, XPathResult.ANY_TYPE, null); 
var thisHeading = headings.iterateNext();  

var headings2 = document.evaluate("//A", thisHeading, null, XPathResult.ANY_TYPE, null); 

headings2.iterateNext().style.backgroundColor = "red";

I need to be able to search for children of an element via xpath.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T19:06:45+00:00Added an answer on May 26, 2026 at 7:06 pm

    You have to use XPathResult.FIRST_ORDERED_NODE_TYPE in conjunction with singleNodeValue to get the first element of the XPath expression. Then, use .//A to select any <a> element, which is a child of the matched node. If you want to match a direct child, use ./A:

    var headings = document.evaluate("//BODY/CENTER[1]/P[1]/TABLE[1]/TBODY[1]/TR[1]",
                         document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null); 
    var thisHeading = headings.singleNodeValue;    
    var headings2 = document.evaluate(".//A", thisHeading, null, XPathResult.ANY_TYPE, null); 
    
    headings2.iterateNext().style.backgroundColor = "red";
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

var links = document.body.querySelectorAll(p.sourcelinks a.individual_source_link); for(var i=0;i<links.length;i++) { links[i].onclick = null; } Is my
Hi I have this script: function ajax(){ if (navigator.standalone) return; for (var i= document.links.length;
Works fine in firefox but does nothing in ie. <script type=text/javascript> $(document).ready(function(){ var links
i can reference link with specific id with following code $(document).ready(function(){ $(a#example_link_id).click(function(event){ var url
Ok, here's a problem script. var links = [ 'one', 'two', 'three' ]; for(
<script type=text/javascript src=jquery.js></script> <script> var printLinks = function () { var links = $(.info).code;
I have a jQuery issue I can't get past: (function ($) { var links
I tried some different ways do find rows in a table where a columns
I've got follow source code: <html> <head><script type=text/javascript> function test() { var links =
I am using this code try document := (pDisp as IWebbrowser2).Document AS IHTMLDocument2; Body

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.