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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T14:25:36+00:00 2026-05-31T14:25:36+00:00

I am developing an application with php where I need to use XML files

  • 0

I am developing an application with php where I need to use XML files and transform them by using a XSL style sheet. To load the XML and XSL files I use the following:

$xsl = new DOMDocument();
$xsl->load("myxslfile.xsl");  // load XSL
$xml = new DOMDocument(); 
$xml->load("myxmlfile.xml");  // load XML

the problem is when running the code the next error appears:

Fatal error: Class 'MyDirectory\DOMDocument' not found in 'mydirectory'

Running phpinfo() I can see dom is intalled and enabled. I don’t know why I can’t run DOMDocument()

  • 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-31T14:25:37+00:00Added an answer on May 31, 2026 at 2:25 pm

    You are apparently using the namespace MyDirectory. But DOMDocument is a class in the global namespace. To reference a class from the global namespace in a local namespace you have to use the Fully Qualified Name or import it into the local namespace:

    Fully Qualified Namespace:

    $xsl = new \DOMDocument();
    $xsl->load("myxslfile.xsl");  // load XSL
    $xml = new \DOMDocument(); 
    $xml->load("myxmlfile.xml");  // load XML
    

    Importing with use

    namespace MyDirectory;
    use \DOMDocument;
    
    $xsl = new DOMDocument();
    $xsl->load("myxslfile.xsl");  // load XSL
    $xml = new DOMDocument(); 
    $xml->load("myxmlfile.xml");  // load XML
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am developing a PHP/MySQL application using vertrigoserver. I need to enter the German
I am currently developing a medium sized web application using PHP and need to
I am developing a PHP application using our XAMPP setup as a test server.
I'm currently developing a PHP application that's using an Access database as a backend.
I am developing an web application using php. One of the requirement is the
I am developing an application using PHP but I am new to regular expressions,
I am developing a form for a PHP application and I need to have
I am developing a Cocoa/Objective-C application. I need to use an external device to
I'm developing a PHP-based application that requires internationalization (i18n) support. I'm using Smarty 3
I am currently developing a php application using MVC techniques. I started it without

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.