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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T18:26:47+00:00 2026-05-15T18:26:47+00:00

When creating a DOMDocument with DOMImplementation::createDocument() , you can specify a doctype as the

  • 0

When creating a DOMDocument with DOMImplementation::createDocument(), you can specify a doctype as the third argument in the constructor. This doctype then gets “tied” to the document and you can retrieve it later with $document->doctype.

However, this is a read-only attribute (unlike encoding and version!).

Is there any way to change the doctype property of an existing DOMDocument object?

The only workaround I can think of is to create a new DOMDocument with the new doctype, and import then copy across the contents from the old one.

  • 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-15T18:26:48+00:00Added an answer on May 15, 2026 at 6:26 pm

    It also seems possible to call $document->loadXML() again even if the document is already populated. It wipes the document and regenerates it, but it is a way of changing the doctype variable on an existing object, and the new doctype does have an HTML representation unlike in my other solution.

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

Sidebar

Related Questions

I'm creating a class that can read from a dicom file. This is basically
I am creating XML files with PHP DOMDocument, and these XML files can not
In a nutshell: creating a xml document with PHP DOMDocument(). Need to add a
(creating a separate question after comments on this: Javascript redeclared global variable overrides old
I'm using the a wrapper around the PHP5-class DOMDocument to generate my HTML. This
Ok, I have just spent the whole day playing with DomDocument and creating some
I'm creating a xml file with the DOMDocument class in php. I want to
Creating a ruby on rails site and recently added: <% if (?can :manage, :table)
Creating MVC3 Razor Helper like Helper.BeginForm() says that it can be done using extension
Creating a mini-database with access, i came across this problem: For the background, i

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.