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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T03:48:16+00:00 2026-05-14T03:48:16+00:00

For one of my projects, I’m using the DOMDocument class to load and manipulate

  • 0

For one of my projects, I’m using the DOMDocument class to load and manipulate XML documents.

I’d need to retrieve every namespace used in the document; however, I can’t find how I’d do that. The DOMDocument class has methods to get the namespace prefix of an URI or the URI of a namespace prefix, but I’ve seen nothing to actually enumerate registered namespaces.

The SimpleXML library has a getNamespaces() method for that. Is there an equivalent for 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-14T03:48:16+00:00Added an answer on May 14, 2026 at 3:48 am

    DOM does not have such a function afaik. I’ve looked briefly at the source code of SimpleXml and I think it iterates the loaded XML and collects the namespaces (my C is very bad). The easiest solution would be to fetch the namespaces by importing the DOM dom into SimpleXml for this purpose. Maybe like this:

    class DomUtils
    {
        public static function getNamespaces($dom)
        {
            $sxe = simplexml_import_dom($dom);
            return $sxe->getNamespaces(); 
        }
    
        public static function getDocNamespaces($dom)
        {
            $sxe = simplexml_import_dom($dom);
            return $sxe->getDocNamespaces();
        }
    }
    

    You could also try to get all namespaces with XPath. See the following question and answers:

    • How to retrieve namespaces in XML files using Xpath
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In one of my projects I need to build an ASP.NET page and some
I started using subversion for one of my projects and it would be absolutely
Having two projects: one is a class library (a .dll assembly) and the other
I've two Visual Basic 2008 projects - one is a class library project and
I am using FullCalendar in one my projects and would like to plot recurring
One of my projects needs to load audio from audio library. It works on
I'm working on a solution that has two projects: One ASP.NET web application, and
I've got a junk directory where I toss downloads, one-off projects, email drafts, and
One of my projects use the MyISAM engine in MySQL, but I'm considering changing
In one of the projects I've worked on, the subject of isomorphism versus monomorphism

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.