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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T22:18:46+00:00 2026-05-22T22:18:46+00:00

Here is a snippet from the XML file I am trying to parse: <Item

  • 0

Here is a snippet from the XML file I am trying to parse:

<Item xsi:type="TextureItem" Name="Texture_0044" Visible="true">
    <Position>
        <X>240</X>
        <Y>432</Y>
    </Position>
    <CustomProperties>
        <Property Name="type" Type="string" Description="slot_rectangle">
            <string />
        </Property>
    </CustomProperties>
    <Rotation>0</Rotation>
    <Scale>
        <X>1</X>
        <Y>1</Y>
    </Scale>
    <TintColor>
        <R>255</R>
        <G>255</G>
        <B>255</B>
        <A>255</A>
        <PackedValue>4294967295</PackedValue>
    </TintColor>
</Item>

I’m using an XmlResourceParser object to parse the XML file and here is my code so far:

XmlResourceParser xrp = context.getResources().getXml(R.xml.level_1);

int eventType = xrp.getEventType();
while (eventType != XmlPullParser.END_DOCUMENT) {
    if(eventType == XmlPullParser.START_DOCUMENT) {
        //System.out.println("Start document");
    } else if(eventType == XmlPullParser.START_TAG) {
        //System.out.println("Start tag "+xrp.getName());
        if (xrp.getName().equals("Item")) {
            //...
        }
    } else if(eventType == XmlPullParser.END_TAG) {
        //System.out.println("End tag "+xrp.getName());
    } else if(eventType == XmlPullParser.TEXT) {
        //System.out.println("Text "+xrp.getText());
    }
    eventType = xrp.next();
}
System.out.println("End document");
xrp.close();

What I’m trying to do is have it so that every time a Item tag is found it will get the “Description” value of the Property tag, the text values of the X and Y tags inside the Position tag, and the text value of the Rotation tag and nothing more.

Right now I’m considering where it says if (xrp.getName().equals(“Item”)) just copying and pasting the outside parsing code to the inside of that if condition and then going up and down in levels getting the values I want until the END_TAG for the Item tag event occurs, but that seems very inefficient and confusing.

What I want sort of is like a xrp.Item.Position.X.getText() sort of deal if you know what I mean, does something like that exist?

Thanks!

  • 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-22T22:18:47+00:00Added an answer on May 22, 2026 at 10:18 pm

    You’re on the right track. Just create an object model that maps to what you expect and fill it in as you parse the XML. You’ll be better off having a light-weight representation of the data instead of trying to use xpath as you need values.

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

Sidebar

Related Questions

No related questions found

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.