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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T05:32:50+00:00 2026-06-13T05:32:50+00:00

Below is the XML I’m trying to parse with DOM, my code and my

  • 0

Below is the XML I’m trying to parse with DOM, my code and my output. I need to get the information out of “Simple data” but I’m failing to do so.

XML:

<kml>
  <Document>
    <Folder id="kml_ft_Meter_Rates_and_Time_Limits">
      <name>Meter_Rates_and_Time_Limits</name>
      <Placemark id="kml_1">
        <name>$1.00 / hr 2hr time limit</name>
        <snippet> </snippet>
        <description><![CDATA[<center><table><tr><th colspan='2' align='center'><em>Attributes</em></th></tr><tr bgcolor="#E3E3F3">
          <th>RATE</th>
          <td>$1.00</td>
          </tr><tr bgcolor="">
          <th>LIMIT</th>
          <td>2hr</td>
          </tr></table></center>]]>
        </description>
        <styleUrl>#ParkingMeterStyler_KMLStyler</styleUrl>
        <ExtendedData>
          <SchemaData schemaUrl="#Meter_Rates_and_Time_Limits">
            <SimpleData name="RATE">$1.00</SimpleData>
            <SimpleData name="LIMIT">2hr</SimpleData>
          </SchemaData>
        </ExtendedData>
        <LineString>
          <coordinates>-123.100739208611,49.2630169018194,0 -123.100348847572,49.2630078055425,0 </coordinates>
        </LineString>
      </Placemark>
    </Folder>
  </Document>
</kml>

Code filled with sysouts for debugging purposes:

        System.out.println("Root element :" + doc.getDocumentElement().getNodeName());
        System.out.println("Root 1st child :" + doc.getDocumentElement().getChildNodes().item(1).getNodeName());
        System.out.println("Document 1st child :" + doc.getDocumentElement().getChildNodes().item(1).getChildNodes().item(1).getNodeName());
        System.out.println("Document 2nd child :" + doc.getDocumentElement().getChildNodes().item(1).getChildNodes().item(2).getNodeName());
        System.out.println("Document 3rd child :" + doc.getDocumentElement().getChildNodes().item(1).getChildNodes().item(3).getNodeName());
        System.out.println("Document 4th child :" + doc.getDocumentElement().getChildNodes().item(1).getChildNodes().item(4).getNodeName());
        System.out.println("Document 5th child :" + doc.getDocumentElement().getChildNodes().item(1).getChildNodes().item(5).getNodeName());
        System.out.println("-----------------------");


        NodeList nList = doc.getElementsByTagName("Placemark");
        nList = nList.item(1).getChildNodes();
        System.out.println("Placemark list, 1st placemark 1st child :" + nList.item(1).getNodeName());
        System.out.println("Placemark list, 1st placemark 2nd child :" + nList.item(2).getNodeName());
        System.out.println("Placemark list, 1st placemark 3rd child :" + nList.item(3).getNodeName());
        System.out.println("Placemark list, 1st placemark 4th child :" + nList.item(4).getNodeName());
        System.out.println("-----------------------");
        System.out.println("Placemark list, 1st placemark 9th child :" + nList.item(9).getNodeName());
        System.out.println("-----------------------");
        nList = nList.item(9).getChildNodes();
        System.out.println("Extended data, 1st child :" + nList.item(1).getNodeName());
        System.out.println("-----------------------");
        System.out.println("Schema data, 1st child :" + nList.item(1).getChildNodes().item(1).getNodeName());
        System.out.println("Simple data :" + nList.item(1).getChildNodes().item(4).getNodeName());
        System.out.println("-----------------------");
        System.out.println("Schema data, 2nd child :" + nList.item(1).getChildNodes().item(3).getNodeName());
        System.out.println("Simple data :" + nList.item(1).getChildNodes().item(4).getNodeName());

Console output:

Root element :kml
Root 1st child :Document
Document 1st child :name
Document 2nd child :#text
Document 3rd child :visibility
Document 4th child :#text
Document 5th child :Style
-----------------------
Placemark list, 1st placemark 1st child :name
Placemark list, 1st placemark 2nd child :#text
Placemark list, 1st placemark 3rd child :snippet
Placemark list, 1st placemark 4th child :#text
-----------------------
Placemark list, 1st placemark 9th child :ExtendedData
-----------------------
Extended data, 1st child :SchemaData
-----------------------
Schema data, 1st child :SimpleData
Simple data :#text
-----------------------
Schema data, 2nd child :SimpleData
Simple data :#text
  • 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-13T05:32:52+00:00Added an answer on June 13, 2026 at 5:32 am

    nList.item(0).getChildNodes().item(9).getChildNodes().item(1).getChildNodes().item(1).getTextContent() –> prints $1.00 and

    nList.item(0).getChildNodes().item(9).getChildNodes().item(1).getChildNodes().item(3).getTextContent() –> prints the 2hr.

    Here nList is used after this line NodeList nList = doc.getElementsByTagName("Placemark");. Please fix your traversal accordingly.

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

Sidebar

Related Questions

Given the XML below, I need to parse it and output names of all
I am trying to parse the below xml in sql server to get all
In the below xml code, I need to get b1 and b2 as my
I am trying to parse the below XML in to the Entity through Linq,
I am trying to read the below xml file and get the name-value pairs
I need to get the value 3 from the below xml file using groovy
I am using the below code to iterate through multiple nodes of XML but
i am trying to traverse a node attributes ..in below xml ,i need to
Im trying to get some values from the below xml feed <?xml version=1.0 ?>
I need to get the content of the POIssuedDate tag of the below XML

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.