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

  • SEARCH
  • Home
  • 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 6169857
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T22:55:44+00:00 2026-05-23T22:55:44+00:00

The following HTML shows the 3rd search (search for Practice Guidelines Professional) does not

  • 0

The following HTML shows the 3rd search (search for “Practice Guidelines Professional”) does not work as the text “Practice Guidelines” is placed between the <strong></strong> tag… Is it possible to achieve XPath search to bypass HTML tags between the texts?

<html>
<head>
<meta http-equiv="X-UA-Compatible" content="chrome=1">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<title>Xpath Test</title>

<script type="text/javascript">
var search = function (button) {
    var searchTxt = button.value;
    var xpath = '//*[contains(translate(text(),\'ABCDEFGHIJKLMNOPQRSTUVWXYZ\', \'abcdefghijklmnopqrstuvwxyz\'), \'' + searchTxt.toLowerCase() + '\')]';
    var nodes = null;

    if (document.evaluate) { 
        nodes = document.evaluate(
          xpath,
          document,
          null,
          XPathResult.ORDERED_NODE_ITERATOR_TYPE,
          null
        );

        var node = nodes.iterateNext ();
        if (node) {
            while (node) {
                var nodeXpath = createXPathFromElement(node);
                alert("Found!!!\n xpath: " + nodeXpath);
                node = nodes.iterateNext ();
            }
        } else {
            alert("No results found.");
        }
    } else {  
        alert("Your browser does not support the evaluate method!");
    }
  }

  function createXPathFromElement(elm) {
    var allNodes = document.getElementsByTagName('*'); 
    for (segs = []; elm && elm.nodeType == 1; elm = elm.parentNode) 
    {  
        for (i = 1, sib = elm.previousSibling; sib; sib = sib.previousSibling) { 
            if (sib.localName == elm.localName)  i++; 
        };
        segs.unshift(elm.localName.toLowerCase() + '[' + i + ']'); 
    }; 
    return segs.length ? '//' + segs.join('//') : null; 
  }
</script>
</head>

<body>
<table>
    <tr>
        <td>
            <p>&#160;</p><h3><strong><span class="color-1">PRINCIPLES OF PATIENT CARE</span></strong></h3><p class="noindent"><strong><span class="color-1">Evidence-Based Medicine</span></strong> Evidence-based medicine refers to the concept that clinical decisions are formally supported by data, preferably data that are derived from prospectively designed, randomized, controlled clinical trials. This is in sharp contrast to anecdotal experience, which may often be biased. Unless they are attuned to the importance of using larger, more objective studies for making decisions, even the most experienced physicians can be influenced by recent encounters with selected patients. Evidence-based medicine has become an increasingly important part of the routine practice of medicine and has led to the publication of a number of practice guidelines.</p>
            <p>&#160;</p><p class="noindent"><strong><span class="color-1">Practice Guidelines</span></strong> Professional organizations and government agencies are developing formal clinical-practice guidelines to aid physicians and other caregivers in making diagnostic and therapeutic decisions that are evidence-based, cost-effective, and most appropriate to a particular patient and clinical situation. As the evidence base of medicine increases, guidelines can provide a useful framework for managing patients with particular diagnoses or symptoms. They can protect patients—particularly those with inadequate health care benefits—from receiving substandard care. Guidelines can also protect conscientious caregivers from inappropriate charges of malpractice and society from the excessive costs associated with the overuse of medical resources. There are, however, caveats associated with clinical practice guidelines since they tend to oversimplify the complexities of medicine. Furthermore, groups with differing perspectives may develop divergent recommendations regarding issues as basic as the need for periodic sigmoidoscopy in middle-aged persons. Finally, guidelines do not—and cannot be expected to—account for the uniqueness of each individual and his or her illness. The physician’s challenge is to integrate into clinical practice the useful recommendations offered by experts without accepting them blindly or being inappropriately constrained by them.</p>               
        </td>
    </tr>
    <tr>
        <td>
            Search for <input type="button" onclick="search(this)" value="Practice Guidelines" /> Success.
        </td>
    </tr>
    <tr>
        <td>
            Search for <input type="button" onclick="search(this)" value="Professional" /> Success.
        </td>
    </tr>
    <tr>
        <td>
            Search for <input type="button" onclick="search(this)" value="Practice Guidelines Professional" /> No result since text 'Practice Guidelines' is inside &lt;strong&gt;&lt;strong/&gt;, and  'Professional' is out side.     
        </td>
    </tr>
</table>
</body>
</html>
  • 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-23T22:55:45+00:00Added an answer on May 23, 2026 at 10:55 pm

    Yes. You can use normalize-space() for this. (line-wrapped for the sake of readability)

    var xpath = "
      //*[
        contains(
          translate(
            normalize-space(.), 
            'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 
            'abcdefghijklmnopqrstuvwxyz'
          ), 
          normalize-space('" + searchTxt.toLowerCase() + "')
        )
      ]
    ";
    

    Note that this will find the entire hierarchy of nodes that contain the respective text, up to and including the <html> element. You would be interested in the “most deeply nested” node, I guess.

    Also note that you might want to remove single quotes from searchTxt as they would break the XPath expression.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following HTML (note the CSS making the background black and text
For example, in the following HTML ... <form name=outerform> <input type=text name=outer1/> <input type=text
The following html snippet <div dir=rtl> test (test) </div> shows
I have the following html in my site: <link type=text/css href=/Styles/ui-lightness/jquery-ui-1.8.2.custom.css rel=Stylesheet /> <link
I have the below code that does not seem to work at all :(
I have the following HTML/JS that shows an initial value, removes it when you
I have the following html: <html> <head></head> <body> <form> <input id=msg type=text value=oldValue />
I have the following little jQuery hack to make any HTML that shows up
I used <%= wicked_pdf_stylesheet_link_tag pdf %> it shows the following output in the html
I'm following this example: http://www.codinghorror.com/blog/2005/12/getting-started-with-indexing-service.html However, the conversion to dataset shows empty columns for

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.