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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T10:21:04+00:00 2026-05-27T10:21:04+00:00

Here is what I have: DOM stored as text I have the string index

  • 0

Here is what I have:

  • DOM stored as text
  • I have the string index of the area I want to get the parent node of, the index may or may not be the beginning of a tag (it will never be a partial of a tag, as it is a user selection
  • I also have the htmltext at the index (obviously)

This is as far as I’ve gotten:

doc = Nokogiri::HTML(content.body)

I know nokogiri can do xpath things, but I don’t know if xpath can do standard text searches? the selection text could span multiple nodes, and I think that breaks xpath searching o.o

I’m using Ruby 1.8.7, and rails 2.3.8

  • 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-27T10:21:04+00:00Added an answer on May 27, 2026 at 10:21 am

    There is no correlation between the index in a particular serialization of the XML Document and an element. The closest you could do:

    Recursively, at each level of the DOM, serialize the element and see if its length (added to what you have so far) has reached your index.

    Unfortunately this is not guaranteed to work, since:

    1. Many different (non-canonical) serializations are possible that describe the same XML document (e.g. foo="You said, "Hi!"" vs. foo='You said, "Hi!"').

    2. Depending on whether you consider blank whitespace nodes as significant, two different XML documents might be treated the same (e.g. <foo><bar> vs. <foo>\n\t<bar>)

    3. In HTML, additional non-significant whitespace might be stripped (e.g. <p>a b</p> vs. <p>a b</p>).

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

Sidebar

Related Questions

I've copied some text nodes from the page (i.e., live DOM) and have stored
I have read the post here about using setTimeout() during intensive DOM processing (using
I'm working with a dynamic DOM here, and have called the jQuery UI datepicker
Here I have: Public Structure MyStruct Public Name as String Public Content as String
I have two data objects stored on different nodes in the dom ie $('node1').data('id','1');
Just wondering what little scripts/programs people here have written that helps one with his
Since upgrading to 2008 I and many people here have noticed that randomly VS
Here I have a password field: /*********************PASSWORD**********************/ $password = new Zend_Form_Element_Password('password'); $alnumValidator = new
Here I have an arbitrary IEnumerable<T> . And I'd like to page it using
Around here we have been working with a bunch of Visual Source Safe repositories

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.