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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T08:07:36+00:00 2026-05-23T08:07:36+00:00

I have an XML file that has the data for multiple pictures such as

  • 0

I have an XML file that has the data for multiple pictures such as GPS coordinates, date/time, and some image data that I need to split into several XML files.

<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://earth.google.com/kml/2.1">
<Document>
    <Placemark>
        <name> //picture 1 info <name>
        <Point>
            <coordinates> //gps 1 cords <coordinates>
        <Point>
    <Placemark>
    <Placemark>
        <name> //picture 2 info <name>
        <Point>
            <coordinates> //gps 2 cords <coordinates>
        <Point>
    <Placemark>
<Document>

I want it to look something like this:

File 1:
<Placemark>
<Name> //picture 1 info <name>
<Point>
    <coordinates> //gps 1 cords <coordinates>
<Point>
<Placemark>

File 2:
<Placemark>
<Name> //picture 2 info <name>
<Point>
    <coordinates> //gps 2 cords <coordinates>
<Point>
<Placemark>

…..I read this question:
Split XML in Multiple XML files

and tried to modify the code a little bit for my file after importing everything. Wondering if anyone had any good ideas on how to modify my code to do the spit like in the question above.

  • 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-23T08:07:37+00:00Added an answer on May 23, 2026 at 8:07 am

    Here is the basic structure you could use if programming on the Android. This would open an xml file from a web address (R.string.XmlUrlAddress). It would then parse the string and write to another file, probably stored on your Android device?

    The commented areas are code that I didn’t write rather than comments on what the code is doing. I didn’t want to take the time to look up the file io code which should be pretty straight forward.

    URL url = new URL(getString(R.string.XmlUrlAddress));
    DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
    DocumentBuilder db = dbf.newDocumentBuilder();
    Document doc = db.parse(new InputSource(url.openStream()));
    doc.getDocumentElement().normalize();
    
    NodeList nodeList = doc.getElementsByTagName("Placemark");
    String[] files = new String[nodeList.getLength()];
    
    for (int i=0; i < nodeList.getLength(); i++) {
        files[i] = "file" + i + ".xml";
        //Create and open files[i] file.
        //Write opening tag.  "<Placemark>"
    
        Node node = nodeList.item(i);
        Element element = (Element)node;
    
        NodeList nameList = element.getElementsByTagName("name");
        Element name = (Element)nameList.item(0);
        nameList = name.getChildNodes();
        String name = nameList.item(0).getNodeValue();
        //Write name to file.  "<name>" + name + "</name>"
    
        NodeList pointList = element.getElementsByTagName("Point");
        String[] points = new String[pointList.getLength()];
    
        //Write opening Points tag. "<Points>"
        for (int j=0; j < pointList.getLength(); j++) {
            Node cNode = pointList.item(j);
            Element cElement = (Element)cNode;
    
            NodeList coordinateList = element.getElementsByTagName("coordinates");
            Element coordinateElement = (Element)coordinateList.item(0);
            coordinateList = coordinateElement.getChildNodes();
            points[j] = coordinateList.item(0).getNodeValue();
    
            //Write points[j] to file. "<coordinates>" + points[j] + "</coordinates>"
        }
        //Write end Points tag.  "</Points>"
        //Write end document tag.  "</Placemark>"
        //Close file
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an 'xml file' file that has some unwanted characters in it <data>
I have a XML file that has the following data, <extcode Type=abc Code=12345 />
I have an XML file that has data in it, but one of the
I have an XML file that has a number of nodes, each of which
I have an XML file that I'm trying to serialize into an object. Some
I have an XML file that I would like to map some attributes of
I have a big (1.9 GB) XML file which has data I want to
I have an XML file that currently has 4 nodes with the same name:
I have an XML file that starts like this: <Elements name=Entities xmlns=XS-GenerationToolElements> I'll have
I have an XML file that encodes a directed acyclic graph (DAG) that represents

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.