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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T04:53:13+00:00 2026-06-18T04:53:13+00:00

I Just discovered domdocument and had previously been using regex.. I need to return

  • 0

I Just discovered domdocument and had previously been using regex..

I need to return the entire form element with all the inputs.

I don’t need to create an entire document i just want that part, in a string that I can manipulate. I have been messing with the following chunk of code trying to make it do something useful, but so far, nothing.

Can anyone make sense of this before I go back to regex?

//get HTML into variable
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, 'https://www.openroadlending.com/Apply.aspx?aid=134');
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$html=curl_exec($curl);

$dom = new domDocument;
@$dom->loadHTML($html);
$dom->preserveWhiteSpace=false;

$xpath = new DOMXPath($dom);
$body = $xpath->query('html/');

echo var_dump($body);

//echo $body->item(0);
$inputs = $xpath->getElementsByTagName('form');

// foreach($inputs as $in){
// $input = $in->saveHTML;
// //echo $input;
// }
  • 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-18T04:53:14+00:00Added an answer on June 18, 2026 at 4:53 am

    you can use this Function

    function DOMinnerHTML($element) 
    { 
       $innerHTML = ""; 
       $children = $element->childNodes; 
       foreach ($children as $child) 
       { 
          $tmp_dom = new DOMDocument(); 
          $tmp_dom->appendChild($tmp_dom->importNode($child, true)); 
          $innerHTML.=trim($tmp_dom->saveHTML()); 
       } 
       return $innerHTML; 
    }
    

    and use like this

    $productspec=$dom->getElementsByTagName('form')
    foreach($productspec as $data)
    { 
       echo DOMinnerHTML($data);
    }
    

    and You Can Use This function for Get Element By Class

    function GetBYClass($Doc,$ClassName){
        $finder = new DomXPath($Doc);
        return($finder->query("//*[contains(@class, '$ClassName')]"));
    } 
    

    and This function Is Not Related To This Question But It Useful

    function ExtractText($node) {
         if($node==NULL)return false;    
         if (XML_TEXT_NODE === $node->nodeType || XML_CDATA_SECTION_NODE === $node->nodeType) {
             return $node->nodeValue;
         } else if (XML_ELEMENT_NODE === $node->nodeType || XML_DOCUMENT_NODE === $node->nodeType || XML_DOCUMENT_FRAG_NODE === $node->nodeType) {
           if ('script' === $node->nodeName) return '';
    
         $text = '';
         foreach($node->childNodes as $childNode) {
            $text .= $this->extractText($childNode);
         }
         return $text;
         }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I just discovered pyplot.scatter and have been playing with it a bit. I'm having
I just discovered that Except() will remove all elements in the second list from
I have just discovered a nasty memory leak using both each_array() and each_arrayref() from
I just discovered the following: As I expected, releasing my object before I return
I just discovered Ruby's metaprogramming (after 7 years of using Ruby, it was about
Just discovered that the structure of my file could be different and my regex
Just discovered this incredible library, but am a bit overwhelmed with all the options.
I just discovered the bzr-upload plugin and thought it was the answer to all
I just discovered this problem today, and I had no idea what caused this
I just discovered the rails-settings gem and now I need to make an admin

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.