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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T01:26:16+00:00 2026-06-18T01:26:16+00:00

I am new to xml file reading in android. I looked up google for

  • 0

I am new to xml file reading in android. I looked up google for this but could not get an appropriate solution.

I wish to parse this xml file

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
        <key>aaaa</key>
        <array>
                <string>b</string>
                <string>c</string>
                <string>d</string>
                <string>e</string>
                <string>f</string>
        </array>
        <key>bbbb</key>
        <array>
                <string>g</string>
                <string>h</string>
                <string>i</string>
                <string>j</string>
                <string>k</string>
        </array>
</dict>
</plist>

After parsing, I wish to obtain the following correspondance:

aaaa [b,c,d,e,f] -> a list/array

bbbb [g,h,i,j,k] -> a list/array

In other words, every string(key) should correspond to the array of the strings inside that key.

How do I do it? Also, I would like to know where I should place the xml file. (Is it in the res/raw/ folder ? If yes, then what would be the address of the file?)

  • 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-18T01:26:17+00:00Added an answer on June 18, 2026 at 1:26 am

    A first draw to do that on your own :

    public final class XMLManager {
    
    
    public static HashMap<String, ArrayList<String>> getHmPlist(){
    
        HashMap<String, ArrayList<String>> hmPlist = null;
    
        try {
    
    
            hmPlist = new HashMap<>();
            Document doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(new File("D:\\Loic_Workspace\\Test2\\res\\test.xml"));
            NodeList ndList = doc.getElementsByTagName("key");
            Integer keyLength = ndList.getLength();
            String keyValue = null;
            NodeList ndArray = null;
            Integer ndArrayLength = null;
            ArrayList<String> alElement = null;
    
            for(int i=0;i<keyLength;i++){
                alElement = new ArrayList<>();
                keyValue = ndList.item(i).getTextContent();
                if(keyValue != null){
                    ndArray = ndList.item(i).getNextSibling().getNextSibling().getChildNodes();
                    ndArrayLength = ndArray.getLength();
                    for(int j=0;j<ndArrayLength;j++){
    
                        if(ndArray.item(j).getNodeName().equalsIgnoreCase("string")){
                            alElement.add(ndArray.item(j).getFirstChild().getTextContent());
                        }
    
                    }
    
                    hmPlist.put(keyValue, alElement);
    
                }
    
            }
    
    
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (SAXException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (ParserConfigurationException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    
        return hmPlist;
    
    }
    
    
    
    }
    

    In order to anserw your question regarding res/raw/ folder. Yes you have to put your XML in that folder and used it in your Java code via the R class.

    Hope it helps,

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

Sidebar

Related Questions

I am reading a xml file with: $reader = new XMLReader(); $reader->xml($myXml, NULL, LIBXML_NOWARNIG
This is my xml file. I want to add a new element to all
I'm reading a XML file in a very simple way: XmlTextReader reader = new
This is my first attempt messing with Flash and reading an xml file. I've
I have a xml file which Im reading it from my class <Testclasses> <Class>new
I am newbie in XML parsing world. I found solution for reading xml file
I'm completely new to Android application programming, and I was reading through Google's tutorial:
I have a problem while reading from XML file in action script 3. This
I having XMl file I am Reading All the Xml using this code .
I've created a new .xml file in my layout folder called log.xml . It

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.