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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T06:29:53+00:00 2026-05-16T06:29:53+00:00

The javadoc for the Document class has the following note under getElementById . Note:

  • 0

The javadoc for the Document class has the following note under getElementById.

Note: Attributes with the name “ID” or “id” are not of type ID unless so defined

So, I read an XHTML doc into the DOM (using Xerces 2.9.1).

The doc has a plain old <p id='fribble'> in it.

I call getElementById("fribble"), and it returns null.

I use XPath to get “//*[id=’fribble’]”, and all is well.

So, the question is, what causes the DocumentBuilder to actually mark ID attributes as ‘so defined?’

  • 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-16T06:29:54+00:00Added an answer on May 16, 2026 at 6:29 am

    For the getElementById() call to work, the Document has to know the types of its nodes, and the target node must be of the XML ID type for the method to find it. It knows about the types of its elements via an associated schema. If the schema is not set, or does not declare the id attribute to be of the XML ID type, getElementById() will never find it.

    My guess is that your document doesn’t know the p element’s id attribute is of the XML ID type (is it?). You can navigate to the node in the DOM using getChildNodes() and other DOM-traversal functions, and try calling Attr.isId() on the id attribute to tell for sure.

    From the getElementById javadoc:

    The DOM implementation is expected to
    use the attribute Attr.isId to
    determine if an attribute is of type
    ID.

    Note: Attributes with the name “ID” or
    “id” are not of type ID unless so
    defined.

    If you are using a DocumentBuilder to parse your XML into a DOM, be sure to call setSchema(schema) on the DocumentBuilderFactory before calling newDocumentBuilder(), to ensure that the builder you get from the factory is aware of element types.

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

Sidebar

Ask A Question

Stats

  • Questions 492k
  • Answers 492k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer http://dev.openlayers.org/releases/OpenLayers-2.9/doc/apidocs/files/OpenLayers-js.html Get layer instance(OpenLayers.Layer.Vector) from map.layers array. Iterate over features(OpenLayers.Feature.Vector)… May 16, 2026 at 10:27 am
  • Editorial Team
    Editorial Team added an answer What you should really do is pass the variable to… May 16, 2026 at 10:27 am
  • Editorial Team
    Editorial Team added an answer Create a calculated column in your DSV which provides the… May 16, 2026 at 10:27 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I use javadoc to document my classes and methods. I would like to add
I have a situation where I'd like to execute javadoc in a project that
I have my Eclipse configured to show warnings on missing javadoc comments and tags
I've been looking through the javadoc documentation on Sun's site, trying to find if
I always wondered how to document a method that overrides a message from a
I have a question about where to document logic in javadocs. For example, I
I have the following in my Activity that I use to download a users
I am trying to create graphical representations of existing code. I have tried to
In my job project I have recently been asked to generate POM files via
What do you think is best practice when creating public header files in C++?

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.