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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T17:54:40+00:00 2026-05-13T17:54:40+00:00

I am using PHP’s DOM object to create HTML pages for my website. This

  • 0

I am using PHP’s DOM object to create HTML pages for my website. This works great for my head, however since I will be entering a lot of HTML into the body (not via DOM), I would think I would need to use DOM->createElement($bodyHTML) to add my HTML from my site to the DOM object.

However DOM->createElement seems to parse all HTML entities so my end result ended up displaying the HTML on the page and not the actual renders HTML.

I am currently using a hack to get this to work,

$body = $this->DOM
             ->createComment('DOM Glitch--><body>'.$bodyHTML."</body><!--Woot");

Which puts all my site code in a comment, which I bypass athe comment and manually add the <body> tags.

Currently this method works, but I believe there should be a more proper way of doing this. Ideally something like DOM->createElement() that will not parse any of the string.

I also tried using DOM->createDocumentFragment() However it does not like some of the string so it would error and not work (Along with take up extra CPU power to re-parse the body’s HTML).

So, my question is, is there a better way of doing this other than using DOM->createComment()?

  • 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-13T17:54:40+00:00Added an answer on May 13, 2026 at 5:54 pm

    I spent a lot of time working on Anthony Forloney’s answer, But I cannot seem to get the html to append to the body without it erroring.

    @Mark B: I have tried doing that, but as I said in the comments, it errored on my html.

    I forgot to add the below, my solution:

    I decided to make my html object much simpler and to allow me to do this by not using DOM and just use strings.

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

Sidebar

Related Questions

Using php-sdk I obtain pages in this way: $array = $this->instance->api( '/' . $fb_user
Using PHP I echo out table rows in a loop like this: <?php /*
Using PHP 5.2.4 and the OpenSSL 0.9.8g module I am trying to create a
Using php i wants to make a join query across 2 database. This is
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
Using php/html, I want to retrieve email addresses (plus other information) from MySQL and
Using PHP's ReflectionClass. Is this possible? I want to get a list of methods
Using PHP to try and tackle this problem, but open to other solutions (Python,
Using php's DOMDocument->LoadHTMLFile('test.html'); keeps on returning an error to me, reporting for an error
Using PHP, given a string such as: this is a <strong>string</strong> ; I need

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.