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

  • Home
  • SEARCH
  • 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 6958207
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T15:06:36+00:00 2026-05-27T15:06:36+00:00

I created an XML file and put it in my res folder. I decided

  • 0

I created an XML file and put it in my “res” folder. I decided to use the XmlResourceParser to parse the XML file.

My question is, how do I move to the next level of elements? Specifically, how can I access the child nodes?

Thanks

My XML file looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<encounters>
    <creature id="1" type="humanoid" name="Jon" race="Human" gender="M" age="20" alignment="NE">
        <appearance condition="ragged" skinColor="white" hairColor="brown" size="M" height="70" weight="170"></appearance>
        <stats hp="20" ac="5" ap="5" mp="10" str="11" dex="15" int="15"></stats>
        <inventory wp1="sword" wp2="knife" arm1="leather" arm2="bracers"></inventory>
        <magic attSp1="fireball" attSp2="iceBall" defSp1="minor Shield" defSp2="major Shield"></magic>
        <treasureItems gp="10" sp="25" item1="ring of protection + 1"></treasureItems>
    </creature>
</encounters>

My code so far looks like this:

    //  ***** BEGIN XML PARSING ***** 
    try {
        while (xrp.getEventType() != XmlResourceParser.END_DOCUMENT) {
            if (xrp.getEventType() == XmlResourceParser.START_TAG) {
                String s = xrp.getName();

                if (s.equals("creature")) {
                    encounterID = xrp.getAttributeResourceValue(null, "id", 0);
                    encounterType = xrp.getAttributeValue(null, "type");
                    encounterName = xrp.getAttributeValue(null, "name");
                    encounterRace = xrp.getAttributeValue(null, "race");
                    encounterGender = xrp.getAttributeValue(null, "gender");
                    encounterAge = xrp.getAttributeResourceValue(null, "age", 0);
                    encounterAlignment = xrp.getAttributeValue(null, "alignment");
                }
            }
        }
    } catch (XmlPullParserException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
        // ***** END XML PARSING ***** 
  • 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-27T15:06:37+00:00Added an answer on May 27, 2026 at 3:06 pm

    The following is documentation on how to use the XmlPullParser documentation.

    That being said you want to use the xrp.next() function to move the parser to the next element. This will cycle through all the elements in your XML document in the order that they appear. If you have sub elements, the parser will reach those after touching the START_TAG of the parent element.

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

Sidebar

Related Questions

I made an XML file under my newly created res/menu folder. Menu.xml contains my
I created a file option_menu.xml: in the directory /res/menu/ I created a file menu.java
I have created XML file,but I can't view it/output it.I know there is no
say there is an xml file, which not created by me, with a known
I've created a simple Flex application to fetch an XML file. I need a
friends, i have created custom title bar using following titlebar.xml file with code <?xml
I have created the following vsct file xml. <?xml version=1.0 encoding=utf-8?> <CommandTable xmlns=http://schemas.microsoft.com/VisualStudio/2005-10-18/CommandTable xmlns:xs=http://www.w3.org/2001/XMLSchema>
I created an App.config file in my WPF application: <?xml version="1.0" encoding="utf-8" ?> <configuration>
I have an XML document as follows: <directory> <file><monitored>0</monitored> <xferStatus>1</xferStatus> <name>test1.txt</name> <size>7</size> <created>03/31/10 11:30:02
I've created a simple xml file here: http://roberthan.host56.com/productsNew.xml which is quite simple, the root

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.