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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T02:49:58+00:00 2026-06-07T02:49:58+00:00

I would like to parse the HTML DOM, using PHP; I have a string

  • 0

I would like to parse the HTML DOM, using PHP;

I have a string PN, and I want to detect the Parrent of the DOM Element where PN has been found as content;

Then, with the Parrent Element found, i need all the Childrens of those Elements;

All the other DOM Elements that are not under the Parrent structure, must be ignored;

  • 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-07T02:50:00+00:00Added an answer on June 7, 2026 at 2:50 am

    this is what i managed to write, but i dont know what to write after $node-> in order to obtain the element (h1,h2,div,span) …

    //start xpath
    // Create new DOM object:
    $dom = new DomDocument();
    // Load HTML code:
    @$dom->loadHTML($html);
    $xpath = new DOMXPath($dom);
    $nodes = $xpath->query('//*');
    $data = array();
    foreach ($nodes as $node) {
        $data[] = $node->textContent;
    }
    if( count( $data ) > 0 )
    {
    echo '<br/>xpath<br/>';
    print_r( $data );
    }
    //stop xpath
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an HTML file and i would like to parse through it using
I am using Xerces in Java. I would like to parse an HTML document
I would like to parse an HTML table and disaply contents using XML to
I would like to parse an HTML document using lxml. I am using python
I would like to parse free-text time intervals like the following, using Python: 1
i have a following pattern, inside the html file, that i would like to
I am using PHP's DOM object to create HTML pages for my website. This
I would like to know if there is a simple way to parse HTML
I would like to write a (HTML) parser based on state machine but I
Would like to parse IPv4 address from exit-addresses . Format of the file: ExitNode

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.