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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T18:08:31+00:00 2026-06-17T18:08:31+00:00

Here is a testcase that highlights an error I’ve run into. I think the

  • 0

Here is a testcase that highlights an error I’ve run into. I think the node is being destroyed/garbage collected/something after the function returns — is there a better way I can go about this?

function render($doc) {

    $fragment = $doc -> createDocumentFragment();
    $fragment -> appendXML('<iframe foo="bar"/>');
    return $fragment -> childNodes -> item(0);
}

$doc = new \DOMDocument();
$element = render($doc);

// Exception: Couldn't fetch DOMElement. Node no longer exists
echo $element -> tagName; // fails -- because element no longer exists
  • 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-17T18:08:32+00:00Added an answer on June 17, 2026 at 6:08 pm

    Since you’re creating only one element there is no need to make a fragment. Just create the element and set its attribute.

    function render($doc) {
    
        $element = $doc -> createElement('iframe');
        $element -> setAttribute('foo', 'bar');
        return element;
    }
    
    $doc = new DOMDocument();
    $element = render($doc);
    
    echo $element -> tagName;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've been testing my application and got stuck into error that does not seem
Suppose I need to set an opacity mask on a WPF control that highlights
I imagine this is common enough that it's a solved problem, but being a
While trying to define some mathematical objects using the Numeric prelude I've run into
I followed the instruction here: http://www.grails.org/doc/latest/guide/7.%20Validation.html and added into config.groovy : grails.validateable.classes = [liningtest.Warm']
I've got an application being build by Maven that is a mixed Groovy and
Why am i getting this error message? Testcase: createIndexBatch_usingTheTestArchive(src.LireHandlerTest): Caused an ERROR at/lux/imageanalysis/ColorLayoutImpl java.lang.NoClassDefFoundError:
I have a testcase that looks like this: def MyTestCase(unittest.Testcase): def test_input01(self): input =
I have a function in a module that looks something like this: module MyLibrary
I have a some code that embeds a return_to URL into a redirect (like

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.