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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T04:13:41+00:00 2026-06-06T04:13:41+00:00

So I realize that the docs have the list of node types for the

  • 0

So I realize that the docs have the list of node types for the Node class, but from poking around, I can’t seem to find a way to programmatically get a list of available nodeTypes for a given Node object (short of inspecting the class, pulling every all caps member with a name ending in ‘NODE’, and then sorting by value). Is there any way to do this?

  • 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-06T04:13:42+00:00Added an answer on June 6, 2026 at 4:13 am

    I wish there was something better, but lacking that, I created a new module:

    from xml.dom import Node
    from collections import OrderedDict
    
    if not hasattr(Node, 'get_all_node_types'):
    
        @classmethod
        def get_all_node_types(cls, refresh=False):
    
            if not hasattr(cls, '_type_dict') or refresh:
                unsorted_types = {getattr(cls, name) : name for name in dir(cls) if name.endswith('_NODE')}
                cls._type_dict = OrderedDict(sorted(unsorted_types.items(), key = lambda t : t[0]))
            return cls._type_dict
    
        setattr(Node, 'get_all_node_types', get_all_node_types)
    

    It’s hacky, so I don’t really like it, but as long as it is imported at least once during program execution, I get my new method.

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

Sidebar

Related Questions

I realize that this question has been asked 100times but none that I have
I realize that it can depend on certain things (and obviously how efficient the
(I realize that my title is poor. If after reading the question you have
I realize that I need to use a mailserver so people can contact me,
I realize that Visual Studio has the /P option to generate preprocessed files, but
I have class A, with methods foo and bar, that are implemented by A1
I know this is a basic question, but I can't find other StackOverflow posts
I have read the docs over and over trying to wrap my head around
I realize that keywords and descriptions are old-school SEO techniques and many search engines
I realize that the answer to this question is likely quite obvious (if somewhat

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.