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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T00:22:30+00:00 2026-06-12T00:22:30+00:00

I have following XML code <?xml version=1.0 encoding=windows-1250?> <menu> <item> <id>0</id> <name>Pizzerie u soudu</name>

  • 0

I have following XML code

<?xml version="1.0" encoding="windows-1250"?>
<menu>
  <item>
    <id>0</id>
    <name>Pizzerie u soudu</name>
    <street>Havlíčkova 3</street>
    <city>779 00 Olomouc</city>
    <mobile>777035862</mobile>
    <telephone>585223042</telephone>
    <openinghours>10-22</openinghours>
  </item>
  <item>
    <id>1</id>
    <name>Pepinova pizza</name>
    <street>©meralova 10</street>
    <city>779 00 Olomouc</city>
    <mobile>776102022</mobile>
    <telephone>-</telephone>
    <openinghours>8-22</openinghours>
  </item>
</menu>

and I would like to parse it by following code:

XMLParser parser = new XMLParser();
String xml = parser.getXmlFromUrl(URL);

Document doc = parser.getDomElement(xml);
NodeList nl = doc.getElementsByTagName("item");

        for (int i = 0; i < nl.getLength(); i++) {
            HashMap<String, String> map = new HashMap<String, String>();
            Element e = (Element)nl.item(i);
            map.put(KEY_ID, parser.getValue(e, KEY_ID));
            map.put(KEY_NAME, parser.getValue(e, KEY_NAME));
            map.put(KEY_STREET, parser.getValue(e, KEY_STREET));
            map.put(KEY_CITY, parser.getValue(e, KEY_CITY));
            map.put(KEY_MOBILE, parser.getValue(e, KEY_MOBILE));
            map.put(KEY_TELEPHONE, parser.getValue(e, KEY_TELEPHONE));
            map.put(KEY_OPENINGHOURS, parser.getValue(e, KEY_OPENINGHOURS));
            menuItems.add(map);
        }

but I have problem on line

NodeList nl = doc.getElementsByTagName("item");

It returns java.lang.NullPointerException
What’s wrong?

  • 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-12T00:22:31+00:00Added an answer on June 12, 2026 at 12:22 am

    It appears to me that you XMLParser code is your proprietary and getDomElement method is returning NULL for some reason like file is not found in path or some other errors. Even if the standard API’s please check whether there are any condition that returns doc value as NULL.

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

Sidebar

Related Questions

I have the following .xsd code: <?xml version=1.0 encoding=UTF-8?> <xs:schema xmlns:xs=http://www.w3.org/2001/XMLSchema id=MyDataSet> <xs:element name=Row>
I have XML similar to the following <?xml version=1.0 encoding=utf-8?> <foo name=FooBar xmlns=http://mydomain/myapp/ver/myschema.xsd> <bars
I have a code with XML output as <?xml version=1.0 encoding=windows-1252 standalone=yes?> <products> <product>
I have the following xml code in a document called note.xml <?xml version="1.0" encoding="ISO-8859-1"?>
I have the following xsl <?xml version=1.0 encoding=windows-1251?> <xsl:stylesheet version=1.0 xmlns:xsl=http://www.w3.org/1999/XSL/Transform> <xsl:param name=currentPage>Buildings</xsl:param> <xsl:template
Learning xml, Can anyone help me? I have following XML code: **<book lang=en>name of
I have the following file Log4net.config in my bin directory: <?xml version=1.0 encoding=utf-8 ?>
I have the following XML document <?xml version='1.0' encoding='UTF-8'?><entry xmlns='http://www.w3.org/2005/Atom' xmlns:gd='http://schemas.google.com/g/2005' xmlns:issues='http://schemas.google.com/projecthosting/issues/2009' gd:etag='W/DEAERH47eCl7ImA9WhZTFEQ.'><id>http://code.google.com/feeds/issues/p/chromium/issues/full/921</id><published>2008-09-03T22:51:22.000Z</published><updated>2011-03-19T01:05:05.000Z</updated><title>Incorrect rendering</title><content
I have the following XML file: <?xml version='1.0' encoding='utf-8'?> <Answers> <Question1 q=What is your
I have the following XML file: <?xml version='1.0' encoding='utf-8'?> <Answers> <Question1 q=What is your

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.