I would use JAXB, see example here http://www.mkyong.com/java/jaxb-hello-world-example/

Answer from Evgeniy Dorofeev on Stack Overflow
Top answer
1 of 2
3

You should use hash map when you dont know the fields

The rite way for you problem is to build a pojo class like this

public class MyPojo
{
    private Entities Entities;

    public Entities getEntities ()
    {
        return Entities;
    }

    public void setEntities (Entities Entities)
    {
        this.Entities = Entities;
    }

    @Override
    public String toString()
    {
        return "ClassPojo [Entities = "+Entities+"]";
    }
}


public class Entities
{
    private String TotalResults;

    private Entity[] Entity;//you can use List<> insted 

    public String getTotalResults ()
    {
        return TotalResults;
    }

    public void setTotalResults (String TotalResults)
    {
        this.TotalResults = TotalResults;
    }

    public Entity[] getEntity ()
    {
        return Entity;
    }

    public void setEntity (Entity[] Entity)
    {
        this.Entity = Entity;
    }

    @Override
    public String toString()
    {
        return "ClassPojo [TotalResults = "+TotalResults+", Entity = "+Entity+"]";
    }
}

I have made 2 pojos for your better understanding

you can create the rest as related to xml. Later you can just use

            File file = new File("My.xml");
            JAXBContext jaxbContext = JAXBContext.newInstance(MyPojo.class);

            Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller();
            MyPojo myPojo = (MyPojo) jaxbUnmarshaller.unmarshal(file);
            System.out.println(myPojo);//get your value with getter setter.

//Description, id and name can be retrieved.

In general, you use a Collection (List, Map, Set) to store objects with similar characteristics, that's why generics exist.

2 of 2
1

You can visit this tutorial for parsing the XML file in java XML Parsing In Java

Then you just need to store in a hashmap.

Discussions

How to read values from xml and store it in hash map in java - Stack Overflow
I am new to xml parsing.I have to retrieve these particular fields (USERNAME,PASSWORD) and needs to save in a hashmap in java . More on stackoverflow.com
🌐 stackoverflow.com
java - how to parse xml to hashmap? - Stack Overflow
I have an example of an xml I want to parse attribute 1 of detail a ... More on stackoverflow.com
🌐 stackoverflow.com
December 6, 2016
How to convert XML to java.util.Map and vice versa? - Stack Overflow
I'm searching a lightweight API (preferable single class) to convert a Map map = new HashMap More on stackoverflow.com
🌐 stackoverflow.com
What’s the easiest way to parse a XML file into nested hashmap?
Please ensure that: Your code is properly formatted as code block - see the sidebar (About on mobile) for instructions You include any and all error messages in full - best also formatted as code block You ask clear questions You demonstrate effort in solving your question/problem - plain posting your assignments is forbidden (and such posts will be removed) as is asking for or giving solutions. If any of the above points is not met, your post can and will be removed without further warning. Code is to be formatted as code block (old reddit/markdown editor: empty line before the code, each code line indented by 4 spaces, new reddit: https://i.imgur.com/EJ7tqek.png ) or linked via an external code hoster, like pastebin.com, github gist, github, bitbucket, gitlab, etc. Please, do not use triple backticks (```) as they will only render properly on new reddit, not on old reddit. Code blocks look like this: public class HelloWorld { public static void main(String[] args) { System.out.println("Hello World!"); } } You do not need to repost unless your post has been removed by a moderator. Just use the edit function of reddit to make sure your post complies with the above. If your post has remained in violation of these rules for a prolonged period of time (at least an hour), a moderator may remove it at their discretion. In this case, they will comment with an explanation on why it has been removed, and you will be required to resubmit the entire post following the proper procedures. To potential helpers Please, do not help if any of the above points are not met, rather report the post. We are trying to improve the quality of posts here. In helping people who can't be bothered to comply with the above points, you are doing the community a disservice. I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns. More on reddit.com
🌐 r/learnjava
6
4
September 22, 2022
🌐
Blogger
pritomkumar.blogspot.com › 2013 › 09 › parse-xml-using-java-and-store-data-in.html
Code Samples: Parse XML using java and store data in HashMap recursively
September 12, 2013 - package xmlparser; import java.io.ByteArrayInputStream; import java.io.File; import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; import org.w3c.dom.Document; import org.w3c.dom.Node; import org.w3c.dom.NodeList; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; /** * * @author Pritom K Mondal * @published 12th September 2013 08:04 PM */ public class XmlParser { private String xmlString = ""; private File xmlFile = null; private Document doc = null; /** * @param args the command li
🌐
Stack Overflow
stackoverflow.com › questions › 69026042 › how-to-read-values-from-xml-and-store-it-in-hash-map-in-java
How to read values from xml and store it in hash map in java - Stack Overflow
public Person deserialization(String name, String path) { Person p=null; try { XMLDecoder decoder = new XMLDecoder(new FileInputStream(new File(path+File.separator+name+".xml"))); p=(Person) decoder.readObject(); decoder.close(); } catch (Exception e) { e.printStackTrace(); } return p; } ... HashMap<String, String> hash_map = new HashMap<String, String>(); hash_map.put(p.getUsername(),p.getPassword()); // p is a Person object
🌐
Coderanch
coderanch.com › t › 380099 › java › hashmaps-xml
hashmaps to xml and back (Java in General forum at Coderanch)
Bill i did try this already but i had a few problems, first properties only stores String, String. my map is String, integer. id rather not have to go through converting the integers to srtings and vice versa the second problem i had (im guessing) is with the way i implemented the code, my xml always turned out like this Satou: i had a look at your example too, but in my code i define the hashmap: i take it this wont make any difference to the example you posted?
Top answer
1 of 3
5

Underscore-java library has a static method U.fromXmlMap(xmlstring). Live example

import com.github.underscore.U;
import java.util.Map;

public class Main {

  public static void main(String[] args) {

    Map<String, Object> map = U.fromXmlMap(
        "<Details>\r\n" + 
        "    <detail-a>\r\n" + 
        "\r\n" + 
        "        <detail> attribute 1 of detail a </detail>\r\n" + 
        "        <detail> attribute 2 of detail a </detail>\r\n" + 
        "        <detail> attribute 3 of detail a </detail>\r\n" + 
        "\r\n" + 
        "    </detail-a>\r\n" + 
        "\r\n" + 
        "    <detail-b>\r\n" + 
        "        <detail> attribute 1 of detail b </detail>\r\n" + 
        "        <detail> attribute 2 of detail b </detail>\r\n" + 
        "\r\n" + 
        "    </detail-b>\r\n" + 
        "\r\n" + 
        "\r\n" + 
        "</Details>");
    
    System.out.println(map);
    // {Details={detail-a={detail=[ attribute 1 of detail a ,  attribute 2 of detail a ,  attribute 3 of detail a ]},
    // detail-b={detail=[ attribute 1 of detail b ,  attribute 2 of detail b ]}}, #omit-xml-declaration=yes}
  }
}
2 of 3
3

Use JAXB to read from xml and save it to a custom object.

Custom object class:

import java.util.List;

import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;

@XmlRootElement(name = "Details")
@XmlType(propOrder = { "detailA", "detailB" })
public class Details {
    private List<String> detailA;
    private List<String> detailB;

    public void setDetailA(List<String> detailA) {
        this.detailA = detailA;
    }

    @XmlElementWrapper(name = "detail-a")
    @XmlElement(name = "detail")
    public List<String> getDetailA() {
        return detailA;
    }

    public void setDetailB(List<String> detailB) {
        this.detailB = detailB;
    }

    @XmlElementWrapper(name = "detail-b")
    @XmlElement(name = "detail")
    public List<String> getDetailB() {
        return detailB;
    }
}

Extract the data from your xml into the object, then add contents to a map as desired:

public static void main(String[] args) throws JAXBException, FileNotFoundException {
    System.out.println("Output from our XML File: ");
    JAXBContext context = JAXBContext.newInstance(Details.class);
    Unmarshaller um = context.createUnmarshaller();
    Details details = (Details)um.unmarshal(new FileReader("details.xml"));
    List<String> detailA = details.getDetailA();
    List<String> detailB = details.getDetailB();

    Map<String, String[]> map = new HashMap<String, String[]>();
    map.put("detail-a", detailA.toArray(new String[detailA.size()]));
    map.put("detail-b", detailB.toArray(new String[detailB.size()]));


    for (Map.Entry<String, String[]> entry : map.entrySet()) {
        //key "detail a" value={"attribute 1 of detail a","attribute 2 of detail a","attribute 3 of detail a"}
        System.out.print("Key \"" +entry.getKey()+"\" value={");
        for(int i=0;i<entry.getValue().length;i++){
            if(i!=entry.getValue().length-1){
                System.out.print("\""+entry.getValue()[i]+"\",");
            }
            else{
                System.out.print("\""+entry.getValue()[i]+"\"}");
            }
        }
        System.out.println();
    }
}

Output will be:

Output from our XML File: 
Key "detail-a" value={"attribute 1 of detail a","attribute 2 of detail a","attribute 3 of detail a"}
Key "detail-b" value={"attribute 1 of detail b","attribute 2 of detail b"}

As a note: this will work only for the xml you provided as input in your question, if you need to add more details like detail-c and so on you must define them in your custom object as well.

XML used:

<?xml version="1.0" encoding="utf-8"?>
<Details>
    <detail-a>
        <detail>attribute 1 of detail a</detail>
        <detail>attribute 2 of detail a</detail>
        <detail>attribute 3 of detail a</detail>
    </detail-a>
    <detail-b>
        <detail>attribute 1 of detail b</detail>
        <detail>attribute 2 of detail b</detail>
    </detail-b>
</Details>
🌐
Java Guides
javaguides.net › 2024 › 01 › parsing-xml-to-hashmap-in-java.html
Parsing XML to HashMap in Java
January 10, 2024 - We use SAXBuilder to parse the XML file. We iterate over the child elements of the root element. For each element, we retrieve the value of the key attribute and the text content and then store them in the HashMap.
🌐
Baeldung
baeldung.com › home › java › java collections › java map › how to parse xml to hashmap in java
How to Parse XML to HashMap in Java | Baeldung
June 20, 2025 - XStream and Underscore, with their minimal configuration, are ideal for straightforward XML parsing. Jackson seamlessly maps XML elements to Java objects, offering flexibility and ease of use.
Find elsewhere
Top answer
1 of 13
65

XStream!

Updated: I added unmarshal part as requested in comments..

import com.thoughtworks.xstream.XStream;
import com.thoughtworks.xstream.converters.Converter;
import com.thoughtworks.xstream.converters.MarshallingContext;
import com.thoughtworks.xstream.converters.UnmarshallingContext;
import com.thoughtworks.xstream.io.HierarchicalStreamReader;
import com.thoughtworks.xstream.io.HierarchicalStreamWriter;

import java.util.AbstractMap;
import java.util.HashMap;
import java.util.Map;

public class Test {

    public static void main(String[] args) {

        Map<String,String> map = new HashMap<String,String>();
        map.put("name","chris");
        map.put("island","faranga");

        XStream magicApi = new XStream();
        magicApi.registerConverter(new MapEntryConverter());
        magicApi.alias("root", Map.class);

        String xml = magicApi.toXML(map);
        System.out.println("Result of tweaked XStream toXml()");
        System.out.println(xml);

        Map<String, String> extractedMap = (Map<String, String>) magicApi.fromXML(xml);
        assert extractedMap.get("name").equals("chris");
        assert extractedMap.get("island").equals("faranga");

    }

    public static class MapEntryConverter implements Converter {

        public boolean canConvert(Class clazz) {
            return AbstractMap.class.isAssignableFrom(clazz);
        }

        public void marshal(Object value, HierarchicalStreamWriter writer, MarshallingContext context) {

            AbstractMap map = (AbstractMap) value;
            for (Object obj : map.entrySet()) {
                Map.Entry entry = (Map.Entry) obj;
                writer.startNode(entry.getKey().toString());
                Object val = entry.getValue();
                if ( null != val ) {
                    writer.setValue(val.toString());
                }
                writer.endNode();
            }

        }

        public Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext context) {

            Map<String, String> map = new HashMap<String, String>();

            while(reader.hasMoreChildren()) {
                reader.moveDown();

                String key = reader.getNodeName(); // nodeName aka element's name
                String value = reader.getValue();
                map.put(key, value);

                reader.moveUp();
            }

            return map;
        }

    }

}
2 of 13
44

Here the converter for XStream including unmarshall

public class MapEntryConverter implements Converter{
public boolean canConvert(Class clazz) {
    return AbstractMap.class.isAssignableFrom(clazz);
}

public void marshal(Object value, HierarchicalStreamWriter writer, MarshallingContext context) {
    AbstractMap<String,String> map = (AbstractMap<String,String>) value;
    for (Entry<String,String> entry : map.entrySet()) {
        writer.startNode(entry.getKey().toString());
        writer.setValue(entry.getValue().toString());
        writer.endNode();
    }
}

public Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext context) {
    Map<String, String> map = new HashMap<String, String>();

    while(reader.hasMoreChildren()) {
        reader.moveDown();
        map.put(reader.getNodeName(), reader.getValue());
        reader.moveUp();
    }
    return map;
}
🌐
Level Up Lunch
leveluplunch.com › java › examples › convert-xml-to-from-hashmap-object-xstream
Convert xml to hashmap using xstream | Level Up Lunch
August 21, 2014 - @Test public void deserialize_xml_to_hashmap() { String xmlAsMap = "<map> <entry>"; XStream xStream = new XStream(); xStream.alias("map", java.util.Map.class); @SuppressWarnings("unchecked") Map<Integer, Restaurant> restaurantConverted = (Map<Integer, Restaurant>) xStream .fromXML(xmlAsMap); assertThat(resturantConverted, hasKey(new Integer("1"))); }
Top answer
1 of 2
2

Assume your xml file is "c:/test.xml"

Then use the following code to read and put into a hash map in in the following format as you said
key=Roomnumber value=CoordLt,CoordLn

import java.io.File;
import java.io.IOException;
import java.util.HashMap;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.naming.spi.DirStateFactory.Result;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.OutputKeys;
import javax.xml.transform.Source;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerConfigurationException;
import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;


public class xml {
    public static void main(String[] args) 
    {
        HashMap<String,String>hMap=new HashMap<String, String>();
        File file=new File("c:/test.xml");

        if(file.exists())
        {
           DocumentBuilderFactory factory=DocumentBuilderFactory.newInstance();
            try
            {
                DocumentBuilder builder = factory.newDocumentBuilder();
                Document document=builder.parse(file);
                Element documentElement=document.getDocumentElement();
                NodeList sList=documentElement.getElementsByTagName("section");
                if (sList != null && sList.getLength() > 0)
                {
                    for (int i = 0; i < sList.getLength(); i++)
                    {
                        Node node = sList.item(i);
                        if(node.getNodeType()==Node.ELEMENT_NODE)
                        {
                            Element e = (Element) node;

                            NodeList nodeList = e.getElementsByTagName("Room");

                            String roomName= nodeList.item(0).getChildNodes().item(0)
                                            .getNodeValue();


                             nodeList = e.getElementsByTagName("CoordLt");
                            String coordValues= nodeList.item(0).getChildNodes().item(0)
                                            .getNodeValue();


                            nodeList = e.getElementsByTagName("CoordLn");
                            coordValues=coordValues+","+ nodeList.item(0).getChildNodes().item(0)
                                            .getNodeValue();
                            hMap.put(roomName, coordValues);
                        }
                    }
                }
            } catch(Exception e){
                System.out.println("exception occured");
            }
        }else
        {
            System.out.println("File not exists");
        }

    }
}
2 of 2
0

If you transform the XML using this xslt (which can be done in Java) you get your desired output, If someone sle knows howto load in a hashmap you'll be fine.

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

    <xsl:output method="text" indent="no" omit-xml-declaration ="yes" />

    <xsl:template match="/sections">
            <xsl:apply-templates select="section"/>
    </xsl:template>

  <xsl:template match="section" xml:space="default">
    <xsl:apply-templates select="Room"/>
    <xsl:text>:</xsl:text>
    <xsl:apply-templates select="CoordLt" />
    <xsl:text>,</xsl:text>
    <xsl:apply-templates select="CoordLn"/>
    <xsl:text>;</xsl:text>
  </xsl:template>

</xsl:stylesheet>
🌐
DZone
dzone.com › coding › languages › xml->json->hashmap
XML->JSON->HashMap
February 18, 2013 - 7 Feb, 2013 7:20:50 PM net.sf.json.xml.XMLSerializer getType INFO: Using default type string { “name”: “Jags Inc”, “employees”: [ { "name": "Jagan", "sex": "Male", "dob": "24-jul" }, { "name": "Satya", "sex": "Male", "dob": "24-apr" } ] } name: Jags Inc employees: [{name=Jagan, sex=Male, dob=24-jul}, {name=Satya, sex=Male, dob=24-apr}]
🌐
Coderanch
coderanch.com › t › 501869 › languages › needed-parsing-XML-HashMap
Help needed in parsing XML to a HashMap (XML forum at Coderanch)
November 8, 2013 - These statements could reside in an instruction/configuration file for your generalized reader class. Bill ... Gopi Chand Maddula wrote:I want to make that code as generic as possible which would read any XML and give the HashMap as output Then you are going to have to make your requirements a lot clearer than what they are so far.
🌐
Coderanch
coderanch.com › t › 593048 › languages › Convert-xml-HashMap
Convert xml to HashMap (XML forum at Coderanch)
September 20, 2012 - I would unmarshal the XML to an object (there are libraries to help you do this) and then write a converter which takes the Map and converts it to an object of the same class. At this point, you can then check the two instances for equality. ... I have a hashMap in my project which contains ...
🌐
Stack Overflow
stackoverflow.com › questions › 51125599 › xml-file-should-be-read-and-store-in-java-object-to-use-throughout-application-o
XML file should be read and store in java object to use throughout application on spring mvc - Stack Overflow
I have a xml file which is having all SQL queries. While Application Context gets loaded, from the servlet, I read the file and store it in HashMap which is static and will use that object throught the application.
🌐
RoseIndia
roseindia.net › answers › viewqa › Java-Beginners › 27086-read-from-file-and-store-using-hash-map.html
read from file and store using hash map
July 25, 2012 - DataInputStream class is used to read text File line by line. BufferedReader is also used to read a file in Java · Stoting file name in Map Stoting file name in Map how to store id and file name in map · HOW TO STORE MULTIPLE EMPLOYEE DETAILS TO XML FILE USING JSP?
🌐
Coderanch
coderanch.com › t › 128705 › languages › load-XML-file-hashmap
How to load XML file to hashmap? (XML forum at Coderanch)
Assuming this is the basic item: <unit id="dgs">...etc </unit> 1. With DOM in memory, I get a NodeList of all elements named "unit" 2. Iterating through the nodelist - for each unit Element, get the id attribute value. 3. Store the Element in a Hashmap with the id value as key.
Top answer
1 of 2
2

The program below will parse all of your XML into a Map.

It first constructs a document from the XML...

    DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
    DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
    Document doc = dBuilder.parse(new ByteArrayInputStream(XML.getBytes()));

(Here, XML is just a string constant containing all of the XML you put in your question)

You can then get a list of all the "Application" nodes in the document...

NodeList applicationNodes = doc.getElementsByTagName("Application");

You will then iterate over each of these doing the following...

  1. Get the child nodes of the application element
  2. Find the name and email from the child nodes
  3. Put these values in a map

Code

import java.io.ByteArrayInputStream;
import java.util.HashMap;
import java.util.Map;

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;

import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;

public class Stack {

    public static void main(String[] args) throws Exception {
        DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
        DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
        Document doc = dBuilder.parse(new ByteArrayInputStream(XML.getBytes()));

        Map<String, String> map = readFromDocument(doc);

        for(Map.Entry<String, String> entry : map.entrySet()) {
            System.out.println(entry.getKey() + " = " + entry.getValue());
        }
    }

    private static Map<String, String> readFromDocument(Document doc) {
        Map<String, String> map = new HashMap<>();

        NodeList applicationNodes = doc.getElementsByTagName("Application");

        for(int k = 0; k < applicationNodes.getLength(); k++) {
            Node applicationNode = applicationNodes.item(k);

            NodeList subNodes = applicationNode.getChildNodes();

            String key = null;
            String value = null;

            for(int j = 0; j < subNodes.getLength(); j++) {
                Node node = subNodes.item(j);

                if("Name".equals(node.getNodeName())) {
                    key = node.getTextContent();
                } else if("StatusIO-Email".equals(node.getNodeName())) {
                    value = node.getTextContent();
                }
            }

            if(key == null || value == null) {
                throw new IllegalStateException("Could not find all attributes of node, key=" + key + ", value=" + value);
            }

            map.put(key, value);
        }
        return map;
    }

    private static final String XML = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
            "<Domains>" +
            "    <Domain name=\"Parts\">" +
            "        <Applications>" +
            "            <Application>" +
            "                <Name>Paragon</Name>" +
            "                <StatusIO-Email> component+d6bb9f42-814c-40de-bb3d-c67c8972c8d2@notifications.statuspage.io</StatusIO-Email>" +
            "            </Application>" +
            "            <Application>" +
            "                <Name>PartsAssistanceCenter</Name>" +
            "                <StatusIO-Email>component+066ac96e-c038-477a-b477-9b17d8183a61@notifications.statuspage.io</StatusIO-Email>" +
            "            </Application>" +
            "            <Application>" +
            "                <Name>PartsPricingFeedback</Name>" +
            "                <StatusIO-Email>component+d34dd6d3-b75c-4777-9ed2-99db85dc591d@notifications.statuspage.io</StatusIO-Email>" +
            "            </Application>" +
            "        </Applications>" +
            "    </Domain>" +
            "    <Domain name=\"Admin\">" +
            "        <Applications>" +
            "            <Application>" +
            "                <Name>DealerAgreementSystem</Name>" +
            "                <StatusIO-Email>component+bc3e0990-fa84-4e5f-8ca5-25cec10e82a1@notifications.statuspage.io</StatusIO-Email>" +
            "            </Application>" +
            "            <Application>" +
            "                <Name>DealerFinancialSystem</Name>" +
            "                <StatusIO-Email> component+50c88a69-b630-465e-9538-d42184489987@notifications.statuspage.io</StatusIO-Email>" +
            "            </Application>" +
            "            <Application>" +
            "                <Name>DealerPersonnelMaintencance</Name>" +
            "                <StatusIO-Email>component+74ac5cdb-77d8-4b45-8ead-fe2aa981d8fb@notifications.statuspage.io</StatusIO-Email>" +
            "            </Application>" +
            "            <Application>" +
            "                <Name>DealerWebSiteContentManagement</Name>" +
            "                <StatusIO-Email>component+7b794d21-b74c-4a07-afcf-baab0a9d7384@notifications.statuspage.io</StatusIO-Email>" +
            "            </Application>" +
            "        </Applications>" +
            "    </Domain>" +
            "    <Domain name=\"Sales\">" +
            "        <Applications>" +
            "            <Application>" +
            "                <Name>C3RemarketingProgram</Name>" +
            "                <StatusIO-Email>component+5a19286d-94de-483c-83f2-8f26bcb9eb2e@notifications.statuspage.io</StatusIO-Email>" +
            "            </Application>" +
            "            <Application>" +
            "                <Name>CARFAX</Name>" +
            "                <StatusIO-Email>component+672dc29d-9990-499c-a9b2-1284032dab62@notifications.statuspage.io</StatusIO-Email>" +
            "            </Application>" +
            "            <Application>" +
            "                <Name>CertificateProgram</Name>" +
            "                <StatusIO-Email>component+9a331d90-7576-4b3c-b7bc-f04fe7f43a81@notifications.statuspage.io</StatusIO-Email>" +
            "            </Application>" +
            "            <Application>" +
            "                <Name>CompetitorInformation</Name>" +
            "                <StatusIO-Email>component+ede2b266-b8fb-426f-a2dd-cfa03f91ae22@notifications.statuspage.io</StatusIO-Email>" +
            "            </Application>" +
            "            <Application>" +
            "                <Name>CustomizedDelivery</Name>" +
            "                <StatusIO-Email>component+b5a9668f-8097-4904-8973-f1fa3c914f52@notifications.statuspage.io</StatusIO-Email>" +
            "            </Application>" +
            "            <Application>" +
            "                <Name>DE1</Name>" +
            "                <StatusIO-Email> component+6262e08b-0781-47a6-ac68-1ef36500610b@notifications.statuspage.io</StatusIO-Email>" +
            "            </Application>" +
            "            <Application>" +
            "                <Name>DistributionAndLogistics</Name>" +
            "                <StatusIO-Email>component+89e75ea9-bc54-4c7a-978a-b638241c407a@notifications.statuspage.io</StatusIO-Email>" +
            "            </Application>" +
            "            <Application>" +
            "                <Name>DistributionandLogistics-Sprinter</Name>" +
            "                <StatusIO-Email>component+668f00bc-dea4-4a56-8d99-c4bfc7de6410@notifications.statuspage.io</StatusIO-Email>" +
            "            </Application>" +
            "            <Application>" +
            "                <Name>EuropeanDeliveryProgram</Name>" +
            "                <StatusIO-Email>component+69c8aa70-4fed-4946-97fd-6f08e0128f87@notifications.statuspage.io</StatusIO-Email>" +
            "            </Application>" +
            "            <Application>" +
            "                <Name>ExtendedLimitedWarranty</Name>" +
            "                <StatusIO-Email>component+5ea8d40a-2c5b-438f-9c23-198e1c78c247@notifications.statuspage.io</StatusIO-Email>" +
            "            </Application>" +
            "            <Application>" +
            "                <Name>ExtendedLimitedWarrantyVans</Name>" +
            "                <StatusIO-Email>component+c14c627d-ec5c-4974-ab88-b4f201f48c48@notifications.statuspage.io</StatusIO-Email>" +
            "            </Application>" +
            "            <Application>" +
            "                <Name>F&amp;IPro</Name>" +
            "                <StatusIO-Email> component+bdf17e22-f4e9-4e21-a5b6-a8c25eb72aa0@notifications.statuspage.io</StatusIO-Email>" +
            "            </Application>" +
            "            <Application>" +
            "                <Name>FleetInfo-DealerSite</Name>" +
            "                <StatusIO-Email>component+e2c43815-fcc4-4538-bde3-3f41d763d57a@notifications.statuspage.io</StatusIO-Email>" +
            "            </Application>" +
            "            <Application>" +
            "                <Name>FleetSales-CustomerSite</Name>" +
            "                <StatusIO-Email>component+3805c27a-d2b2-4de5-86e6-d6c35d12ee16@notifications.statuspage.io</StatusIO-Email>" +
            "            </Application>" +
            "            <Application>" +
            "                <Name>GeographicLinesets</Name>" +
            "                <StatusIO-Email> component+94ee1578-1ff1-498f-900a-d6750b55a74f@notifications.statuspage.io</StatusIO-Email>" +
            "            </Application>" +
            "            <Application>" +
            "                <Name>KnownExporterSearch</Name>" +
            "                <StatusIO-Email>component+fb403be8-14b1-4485-851e-c3b0c93a905a@notifications.statuspage.io</StatusIO-Email>" +
            "            </Application>" +
            "            <Application>" +
            "                <Name>ManheimAuctions</Name>" +
            "                <StatusIO-Email>component+0d9e6bdb-ea6a-48a5-ae9f-c496dad09782@notifications.statuspage.io</StatusIO-Email>" +
            "            </Application>" +
            "            <Application>" +
            "                <Name>MarketSupportSystem</Name>" +
            "                <StatusIO-Email>component+864d733f-c9b5-4a66-a67f-94b10a964022@notifications.statuspage.io</StatusIO-Email>" +
            "            </Application>" +
            "            <Application>" +
            "                <Name>MBAdvantage</Name>" +
            "                <StatusIO-Email>component+6301fa14-81a6-4823-aa99-66c0d1244169@notifications.statuspage.io</StatusIO-Email>" +
            "            </Application>" +
            "            <Application>" +
            "                <Name>MBBusDevCenter</Name>" +
            "                <StatusIO-Email>component+7a46434f-143d-4ddc-ad36-099cea6cfac5@notifications.statuspage.io</StatusIO-Email>" +
            "            </Application>" +
            "            <Application>" +
            "                <Name>mbrace-ElectronicSubscriberAgreement</Name>" +
            "                <StatusIO-Email>component+47c62d30-406f-44e8-a55c-6780cc2ec016@notifications.statuspage.io</StatusIO-Email>" +
            "            </Application>" +
            "            <Application>" +
            "                <Name>MercedesProgramInfo</Name>" +
            "                <StatusIO-Email>component+d5cab941-5e62-4134-8e8e-c31f2d3fe5be@notifications.statuspage.io</StatusIO-Email>" +
            "            </Application>" +
            "            <Application>" +
            "                <Name>PrepaidMaintenance</Name>" +
            "                <StatusIO-Email>component+feb2791b-6c76-4047-a068-d989b32c14e2@notifications.statuspage.io</StatusIO-Email>" +
            "            </Application>" +
            "            <Application>" +
            "                <Name>PrepaidMaintenanceVans</Name>" +
            "                <StatusIO-Email>component+115bee7c-6863-4311-806f-ddb485f4e2a5@notifications.statuspage.io</StatusIO-Email>" +
            "            </Application>" +
            "            <Application>" +
            "                <Name>RDAResourceManager</Name>" +
            "                <StatusIO-Email>component+a7024b6c-be83-4814-84ad-e23b9ca7dc30@notifications.statuspage.io</StatusIO-Email>" +
            "            </Application>" +
            "            <Application>" +
            "                <Name>VehicleConfigurator</Name>" +
            "                <StatusIO-Email>component+5beda28e-dfd2-422e-83cb-ca98226db630@notifications.statuspage.io</StatusIO-Email>" +
            "            </Application>" +
            "            <Application>" +
            "                <Name>VehicleWraps</Name>" +
            "                <StatusIO-Email>component+b02e0618-c013-434c-9142-aacc907a7231@notifications.statuspage.io</StatusIO-Email>" +
            "            </Application>" +
            "        </Applications>" +
            "    </Domain>" +
            "    <Domain name=\"Service\">" +
            "        <Applications>" +
            "            <Application>" +
            "                <Name>ASRALocal</Name>" +
            "                <StatusIO-Email>component+704833c3-c7ef-488c-a84e-6818652a9993@notifications.statuspage.io</StatusIO-Email>" +
            "            </Application>" +
            "            <Application>" +
            "                <Name>MarketResearchAfterSales</Name>" +
            "                <StatusIO-Email> component+1008863b-df94-4422-b7d0-24e754c8f92e@notifications.statuspage.io</StatusIO-Email>" +
            "            </Application>" +
            "            <Application>" +
            "                <Name>MOC1TabletSolutions</Name>" +
            "                <StatusIO-Email>component+10a3086f-da72-45ea-8cec-ec12d1aa7fae@notifications.statuspage.io</StatusIO-Email>" +
            "            </Application>" +
            "            <Application>" +
            "                <Name>OperationsGuidelines</Name>" +
            "                <StatusIO-Email>component+952684d7-8561-4ab8-9268-776dcae72c85@notifications.statuspage.io</StatusIO-Email>" +
            "            </Application>" +
            "            <Application>" +
            "                <Name>smartTekInfo</Name>" +
            "                <StatusIO-Email>component+b52b1e02-51a3-48b7-a16b-ba2000cf1c8c@notifications.statuspage.io</StatusIO-Email>" +
            "            </Application>" +
            "            <Application>" +
            "                <Name>smartWarrantyManual</Name>" +
            "                <StatusIO-Email>component+a23c655a-1f0c-4af3-880c-636fb39fe334@notifications.statuspage.io</StatusIO-Email>" +
            "            </Application>" +
            "            <Application>" +
            "                <Name>SeatProtection</Name>" +
            "                <StatusIO-Email>component+29b6c2a0-3a72-4934-8f1e-ecd674503552@notifications.statuspage.io</StatusIO-Email>" +
            "            </Application>" +
            "            <Application>" +
            "                <Name>ServiceandPartsSalesTools</Name>" +
            "                <StatusIO-Email>component+a5226dfc-beeb-4b75-8609-09518ad5140d@notifications.statuspage.io</StatusIO-Email>" +
            "            </Application>" +
            "            <Application>" +
            "                <Name>SmallRepair</Name>" +
            "                <StatusIO-Email>component+892f5cb6-e8aa-4608-9d1f-d97197e37304@notifications.statuspage.io</StatusIO-Email>" +
            "            </Application>" +
            "            <Application>" +
            "                <Name>STARTekInfo</Name>" +
            "                <StatusIO-Email>component+cac881e6-ef80-4b80-a135-ba559ed1abfe@notifications.statuspage.io</StatusIO-Email>" +
            "            </Application>" +
            "            <Application>" +
            "                <Name>WarrantyManual</Name>" +
            "                <StatusIO-Email>component+1f2c68d9-45d5-4eba-9533-1fe31441c44b@notifications.statuspage.io</StatusIO-Email>" +
            "            </Application>" +
            "        </Applications>" +
            "    </Domain>" +
            "</Domains>"; 
}

Output

MarketResearchAfterSales =  component+1008863b-df94-4422-b7d0-24e754c8f92e@notifications.statuspage.io
WarrantyManual = component+1f2c68d9-45d5-4eba-9533-1fe31441c44b@notifications.statuspage.io
F&IPro =  component+bdf17e22-f4e9-4e21-a5b6-a8c25eb72aa0@notifications.statuspage.io
ASRALocal = component+704833c3-c7ef-488c-a84e-6818652a9993@notifications.statuspage.io
MarketSupportSystem = component+864d733f-c9b5-4a66-a67f-94b10a964022@notifications.statuspage.io
ExtendedLimitedWarrantyVans = component+c14c627d-ec5c-4974-ab88-b4f201f48c48@notifications.statuspage.io
CustomizedDelivery = component+b5a9668f-8097-4904-8973-f1fa3c914f52@notifications.statuspage.io
DistributionandLogistics-Sprinter = component+668f00bc-dea4-4a56-8d99-c4bfc7de6410@notifications.statuspage.io
MBBusDevCenter = component+7a46434f-143d-4ddc-ad36-099cea6cfac5@notifications.statuspage.io
RDAResourceManager = component+a7024b6c-be83-4814-84ad-e23b9ca7dc30@notifications.statuspage.io
OperationsGuidelines = component+952684d7-8561-4ab8-9268-776dcae72c85@notifications.statuspage.io
CertificateProgram = component+9a331d90-7576-4b3c-b7bc-f04fe7f43a81@notifications.statuspage.io
PrepaidMaintenance = component+feb2791b-6c76-4047-a068-d989b32c14e2@notifications.statuspage.io
mbrace-ElectronicSubscriberAgreement = component+47c62d30-406f-44e8-a55c-6780cc2ec016@notifications.statuspage.io
DealerPersonnelMaintencance = component+74ac5cdb-77d8-4b45-8ead-fe2aa981d8fb@notifications.statuspage.io
ServiceandPartsSalesTools = component+a5226dfc-beeb-4b75-8609-09518ad5140d@notifications.statuspage.io
MBAdvantage = component+6301fa14-81a6-4823-aa99-66c0d1244169@notifications.statuspage.io
DealerAgreementSystem = component+bc3e0990-fa84-4e5f-8ca5-25cec10e82a1@notifications.statuspage.io
CARFAX = component+672dc29d-9990-499c-a9b2-1284032dab62@notifications.statuspage.io
smartWarrantyManual = component+a23c655a-1f0c-4af3-880c-636fb39fe334@notifications.statuspage.io
DealerWebSiteContentManagement = component+7b794d21-b74c-4a07-afcf-baab0a9d7384@notifications.statuspage.io
MOC1TabletSolutions = component+10a3086f-da72-45ea-8cec-ec12d1aa7fae@notifications.statuspage.io
PartsAssistanceCenter = component+066ac96e-c038-477a-b477-9b17d8183a61@notifications.statuspage.io
ExtendedLimitedWarranty = component+5ea8d40a-2c5b-438f-9c23-198e1c78c247@notifications.statuspage.io
FleetSales-CustomerSite = component+3805c27a-d2b2-4de5-86e6-d6c35d12ee16@notifications.statuspage.io
ManheimAuctions = component+0d9e6bdb-ea6a-48a5-ae9f-c496dad09782@notifications.statuspage.io
Paragon =  component+d6bb9f42-814c-40de-bb3d-c67c8972c8d2@notifications.statuspage.io
MercedesProgramInfo = component+d5cab941-5e62-4134-8e8e-c31f2d3fe5be@notifications.statuspage.io
STARTekInfo = component+cac881e6-ef80-4b80-a135-ba559ed1abfe@notifications.statuspage.io
C3RemarketingProgram = component+5a19286d-94de-483c-83f2-8f26bcb9eb2e@notifications.statuspage.io
DE1 =  component+6262e08b-0781-47a6-ac68-1ef36500610b@notifications.statuspage.io
EuropeanDeliveryProgram = component+69c8aa70-4fed-4946-97fd-6f08e0128f87@notifications.statuspage.io
PartsPricingFeedback = component+d34dd6d3-b75c-4777-9ed2-99db85dc591d@notifications.statuspage.io
SmallRepair = component+892f5cb6-e8aa-4608-9d1f-d97197e37304@notifications.statuspage.io
DistributionAndLogistics = component+89e75ea9-bc54-4c7a-978a-b638241c407a@notifications.statuspage.io
GeographicLinesets =  component+94ee1578-1ff1-498f-900a-d6750b55a74f@notifications.statuspage.io
SeatProtection = component+29b6c2a0-3a72-4934-8f1e-ecd674503552@notifications.statuspage.io
FleetInfo-DealerSite = component+e2c43815-fcc4-4538-bde3-3f41d763d57a@notifications.statuspage.io
PrepaidMaintenanceVans = component+115bee7c-6863-4311-806f-ddb485f4e2a5@notifications.statuspage.io
CompetitorInformation = component+ede2b266-b8fb-426f-a2dd-cfa03f91ae22@notifications.statuspage.io
DealerFinancialSystem =  component+50c88a69-b630-465e-9538-d42184489987@notifications.statuspage.io
VehicleWraps = component+b02e0618-c013-434c-9142-aacc907a7231@notifications.statuspage.io
VehicleConfigurator = component+5beda28e-dfd2-422e-83cb-ca98226db630@notifications.statuspage.io
smartTekInfo = component+b52b1e02-51a3-48b7-a16b-ba2000cf1c8c@notifications.statuspage.io
KnownExporterSearch = component+fb403be8-14b1-4485-851e-c3b0c93a905a@notifications.statuspage.io
2 of 2
1

One way could be to use XPath to get all elements Application then for each of them get the value of the tag Name and StatusIO-Email by calling getTextContent() on the first element returned by getElementsByTagName:

// Parse the data
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
Document doc = builder.parse(myFile);

// Create the XPath expression
XPathFactory xPathfactory = XPathFactory.newInstance();
XPath xpath = xPathfactory.newXPath();
XPathExpression expr = xpath.compile("/Domains/Domain/Applications/Application");

// Evaluate the XPath expression to get all elements Application
NodeList nl = (NodeList) expr.evaluate(doc, XPathConstants.NODESET);

Map<String, String> map = new HashMap<>();
// For each element Application get the value of Name and StatusIO-Email
for (int i = 0; i < nl.getLength(); i++) {
    // Cast it first as an element
    Element node = (Element) nl.item(i);
    map.put(
        node.getElementsByTagName("Name").item(0).getTextContent(),   
        node.getElementsByTagName("StatusIO-Email").item(0).getTextContent()
    );
}

NB: This code assumes that we always have a tag Name and StatusIO-Email in each element Application if not you will need to check first for each tag if it exists.