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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T12:01:59+00:00 2026-06-07T12:01:59+00:00

I’ve been searching for a simple example(s) each for read/ write/ edit XML for

  • 0

I’ve been searching for a simple example(s) each for read/ write/ edit XML for android. The file can be saved in res/raw folder or assets/ other folder of the application file structure. But NO tutorial is proper with easy code samples.

Some tutorials talk about different XML parsers like- SAX, DOM etc but it will be better to have all 3 examples using a particular API/ parser. Unlike SAX which is ONLY to read xml.

http://www.mkyong.com/java/how-to-modify-xml-file-in-java-dom-parser/
This is a good DOM tutorial but it’s not for android. I have problem deciding where to store the xml file !! Creating InputStream & StreamResult or other objects for android.

So please point out some simple examples for 1) read 2) write 3) edit using a SINGLE api/ parser/ framework- say DOM or other. Which also includes where & how to store that file 1) internal storage 2) external (SD)

Hope this also helps other newbies.

  • 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-07T12:02:00+00:00Added an answer on June 7, 2026 at 12:02 pm

    Well I would love to help you on the writing XML portion of your problem if you could still use assistance. Yet I need help myself on the subject of editing the XML. I have an idea of how to edit the XML if I was to use string parsing, but I have no clue of how to go about updating the original XML file… [Sorry if I lost you there.] But I am going to edit a code that has suited me so you can take a peek. 🙂
    -Kai (A NEWB As Well)
    Reading From XML In Android 🙂

    The Demo XML

    <UltraSpecialEvents>
       <UltraSpecialEvent Name= "USE1">
          <UltraSpecialInfo Name="USI1" Detail="Blah" TimeStamp="hh:mm:ss" />
          <UltraSpecialInfo Name="USI2" Detail="Blah Blahs" TimeStamp="hh:mm:ss" />
          <UltraSpecialInfo Name="USI3" Detail="And More Blahs" TimeStamp="hh:mm:ss" />
       </UltraSpecialEvent>
       <UltraSpecialEvent Name= "UnusedGarbageStuff't">
          <UltraSpecialInfo Name="USI1" Detail="Blah" TimeStamp="hh:mm:ss" />
          <UltraSpecialInfo Name="USI2" Detail="Blah Blahs" TimeStamp="hh:mm:ss" />
          <UltraSpecialInfo Name="USI3" Detail="And More Blahs" TimeStamp="hh:mm:ss" />
       </UltraSpecialEvent>
    </UltraSpecialEvents>
    

    Reading The XML

    public ArrayList<ArrayList<String>> get() {
                ArrayList<ArrayList<String>> classes = new ArrayList<ArrayList<String>>();
                try {
                    boolean inTargetedTag = false;
                    XmlPullParser parser = XmlPullParserFactory.newInstance().newPullParser();
                    parser.setInput(inputStream, null);
                    int eventType = parser.getEventType();
                    while (eventType != XmlPullParser.END_DOCUMENT) {
                        switch (eventType) {
                        case XmlPullParser.START_TAG:
                            String tagName = parser.getName();
                            if (tagName.equalsIgnoreCase("UltraSpecialEvent")) {
                                if (parser.getAttributeValue(null, "Name").equals("USE1")) {
                                    inTargetedTag = true;
                                } else {
                                    inTargetedTag = false;
                                }
                            } if (tagName.equalsIgnoreCase("UltraSpecialInfo")) {
                                if (inTargetedTag) {
                                    ArrayList<String> single_Info = new ArrayList<String>();
                                    single_Info.add(parser.getAttributeValue(null, "Name"));
                                    single_Info.add(parser.getAttributeValue(null, "Detail"));
                                    single_Info.add(parser.getAttributeValue(null, "TimeStamp"));
                                    bundled_Info.add(single_Info);
                                }
                            }
                            break;
                        }
                        eventType = parser.next();
                    }
                } catch (FileNotFoundException e) {
                } catch (IOException e) {
                } catch (Exception e) {
                }
                return bundled_Info;
            }
    

    I hope this helps :/

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

Sidebar

Related Questions

I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
I have a jquery bug and I've been looking for hours now, I can't
I have just tried to save a simple *.rtf file with some websites and
In my XML file chapters tag has more chapter tag.i need to display chapters
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
I have a reasonable size flat file database of text documents mostly saved in
I'm parsing an XML file, the creators of it stuck in a bunch social
link Im having trouble converting the html entites into html characters, (&# 8217;) i
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function

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.