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 8420809
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T02:57:35+00:00 2026-06-10T02:57:35+00:00

I have 2 nodesets that have the following contents; obj1 <p>the quick <b>brown</b> fox

  • 0

I have 2 nodesets that have the following contents;

obj1 "<p>the quick <b>brown</b> fox jumped over the fence</p>"
obj2 "<p>the quick <b>brown</b> fox </p>"

I am attempting to match the contents of obj1 with obj2 and then remove the matched nodes to leave behind an object that looks like.

output "<p>jumped over the fence</p>"

Using jquery $.match returns an error and $.find yields no results either, is there any other effective method of doing what I am trying to work out?

  • 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-06-10T02:57:37+00:00Added an answer on June 10, 2026 at 2:57 am

    Not sure if this fits the requirements, but the variables looks like HTML strings to me, and it looks like you want to compare the string word by word whitout loosing the original main element, and I would do something like:

    var obj1 = "<p>the quick <b>brown</b> fox jumped over the fence</p>",
        obj2 = "<p>the quick <b>brown</b> fox </p>";
    
    var obj3 = compare(obj1, obj2);
    
    $('body').append(obj3);
    
    
    function compare(elm1, elm2) {
        var obj = [],
            o1 = String($(elm1).html()).split(' '), //get <p>'s inner HTML as string and split on spaces to get each word
            o2 = String($(elm2).html()).split(' ');
    
        $.each(o1, function(i,e) { //iterate over each word inside <p> of first string
            if (e !== o2[i]) obj.push(e); //check if matches each word in the same loaction in the second string
        });
        //we should now have an array of the words that does not match each other
        return $(elm1).clone().html(obj.join(' ')); //join with new spaces and return the string as html contained in a clone of the original element.
    }
    

    FIDDLE

    FIDDLE as a function to call (seems simpler) !

    Should add that this won’t work for something like :

    var obj1 = "<p>the quick <b>brown</b> fox jumped over the fence</p>",
        obj2 = "<p>fox jumped over the fence</p>";
    

    as those strings does not word for word match, all though the second is part of the first etc. but to remove the similar parts of the string in such an event you could always just do :

    var obj1 = "<p>the quick <b>brown</b> fox jumped over the fence</p>",
        obj2 = "<p>fox jumped over the</p>",
        o1 = String($(obj1).html()),
        o2 = String($(obj2).html());
    
    var obj = $(obj1).clone().html(o1.replace(o2, ''));
    

    FIDDLE

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

Sidebar

Related Questions

I have the following code: // xpath evaluates to net.sf.saxon.xpath.XPathEvaluator XPath xpath = XPathFactory.newInstance().newXPath();
I have an xml file with the following format <someXML> <a> <b></b> <b test='someValue'></b>
I have a NodeSet of a table that looks similar to this: <table cellpadding=1
I have a bunch of nodesets where I want to return 1 instead of
my situation is the following: I have a nodeset, through which I iterate and
I have the following xml: <?xml version=1.0 encoding=utf-8 ?> <ROLES> <ROLE type=A> <USER name=w
Have a simple form that has a PictureBox in one location. I want to
I have a SOAP response that I'm processing in Java. It has a element
I have made the following method which runs hard-coded xPath queries in a hard-coded
I have the following test code... I am trying to pass a node-set as

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.