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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T13:38:56+00:00 2026-05-23T13:38:56+00:00

I am parsing an xml using DOM Parser. I get a doc and then

  • 0

I am parsing an xml using DOM Parser. I get a doc and then from that doc i get a url. when i search through that url for a particular char sequence i receive a null pointer exception.
This is what i am doing:

  Boolean var = false;
  String url = theElement.getChildNodes().item(5).getNodeValue();
    if (url.contains("-b-"))  // this throws exception
    {
      var = true;
    }

Please any suggestions…

  • 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-23T13:38:57+00:00Added an answer on May 23, 2026 at 1:38 pm

    These long chains of “dereference” operations often cause problems if one or more of them results in a null pointer.

    Before setting url, print out the values for:

    theElement
    theElement.getChildNodes()
    theElement.getChildNodes().item(5)
    theElement.getChildNodes().item(5).getNodeValue();
    

    Almost certainly the last one will be a null reference.

    The documentation for String.contains shows no specific exception is thrown, hence the likelihood is high that it’s a null reference (especially, as I’ve just noticed, you explicitly state that it’s a null pointer exception).

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

Sidebar

Related Questions

I'm parsing XML results from an API call using PHP and xpath. $dom =
Parsing an XML file using the Java DOM parser results in: [Fatal Error] os__flag_8c.xml:103:135:
I am parsing a XML file in Java using the W3C DOM. I am
We're parsing an XML document using JAXB and get this error: [org.xml.sax.SAXParseException: Invalid byte
I'm parsing an XML document into my own structure using DOM, but in another
I am parsing through a XML file that's about 12mb big. I need to
How to parse xml element using attribute value. i am using Dom for parsing
I've got the following problem: I'm using the PHP XML DOM parser and when
I have been using DOM for parsing my small xml docs for sometime.Afer reading
I get an XML from website into a string strXML. Then I create an

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.