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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T18:16:41+00:00 2026-05-27T18:16:41+00:00

I have the following html and i am using php’s DomDocument class to get

  • 0

I have the following html and i am using php’s DomDocument class to get the element with id ‘nextPageBtn’ next to the script tag. the problem is my query doesnot return anything (as if there is no element with the specified id). heres the html i am parsing.

<body>
    <div style='float:left'><img src='../../../../includes/ph1.jpg'></div>

    <label style='width: 476px; height: 40px; position: absolute;top:100px; left: 40px; z-index: 2; background-color: rgb(255, 255, 255);; background-color: transparent' >
    <font size="4">1a. Nice to meet you!</font>
    </label>
    <img src='ENG_L1_C1_P0_1.jpg' style='width: 700px; height: 540px; position: absolute;top:140px; left: 40px; z-index: 1;' />

    <script type='text/javascript'> 


    swfobject.registerObject('FlashID');
    </script>

    <input type="image" id="nextPageBtn" src="../../../../includes/ph4.gif" style="position: absolute; top: 40px; left: 795px; ">

    </body>

and heres the php code to parse it.

$doc->loadHTMLFile($path);

    $doc->encoding='UTF-8';
    $x = new DOMXPath($doc);
$nextPage=$x->query("//*[@id='nextPageBtn']")->item(0);
if($nextPage)
    {

    echo 'found it..';
}

I think the line ‘swfobject.registerObject(‘FlashID’)’ is generating some kind of error which is avoiding the element to be found?

  • 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-27T18:16:42+00:00Added an answer on May 27, 2026 at 6:16 pm

    As written in the comment, your code just works flawlessly. Demo: http://codepad.viper-7.com/RUNGOd

    What you consider a source of problem:

    I think the line ‘swfobject.registerObject(‘FlashID’)’ is generating some kind of error which is avoiding the element to be found?

    Hardly can be one as DOMDocument::loadHTMLFile should deal with all tags (otherwise you would have recieved errors/warnings in loading the document. After loading has been done, DOMDocument has normalized data accessible, so there aren’t such issues (if there isn’t a bug in libxml, the underlying library, but there hardly is for such a general thing).

    So what are the options here? Probably the HTML is not the HTML you think of. That could be if loading the HTML fails in your case. Check for errors while loading:

    error_reporting(~0); ini_set('display_errors', 1);
    

    Also validate that the HTML is the HTML you think after loading:

    $doc->loadHTMLFile($path);
    echo $doc->saveHTML();
    

    which will output the “source”.

    Also check your LIBXML version:

    printf("LIBXML version: %s\n", LIBXML_DOTTED_VERSION);
    

    LIBXML is the underlying library PHP’s DOMDocument is based on. Depending on the version there can be bugs and not all features are working. For example the getElementById function doesn’t work with loadHTMLFile/loadHTML with version 2.6.26 but it does with version 2.7.7 (the XPath expression you’re using is not affected with these two versions).

    If you’re running into an encoding issue here (the source file has some other encoding than expected), it’s harder to tell with the information you’ve provided. Internally DOMDocument‘s default encoding is UTF-8 in PHP, so setting:

     $doc->encoding='UTF-8';
    

    after you’ve loaded the file looks superfluous to me. Maybe you should just remove this to reduce the code to easier find a place the error comes from (as I did in the demo).

    • 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 form <form action=/newPost id=submit_new method=get><div class=iwill> <div class=iwill-holder> <div
I'm using PHP mail and I have the following headers: MIME-Version: 1.0 Content-Type: text/html;
I have following view <asp:Content ID=Content2 ContentPlaceHolderID=MainContent runat=server> <h2>Tables <%=ViewData[RetriverName] %></h2> <%using (Html.BeginForm(ResfreshSelectedTables, Home))
Okay, so i have the following html added to a site using javascript/greasemonkey. (just
I have the following in my view: <%using (Html.BeginForm()) {%> <% foreach (var item
I'm using jQuery with rails and have the following piece of code $('#related').html(<%= render
I having trouble in dividing the HTML frames. I have been using the following
I have the following HTML <select> element: <select id=leaveCode name=leaveCode> <option value=10>Annual Leave</option> <option
I have read the following tutorial Uploading Files To the Server Using PHP and
I'm following this tutorial here: http://brenelz.com/blog/implementing-paging-using-php-and-jquery/ Here is what I have: http://eataustineat.com/testingfolder/ I've encountered

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.