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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T21:10:42+00:00 2026-05-30T21:10:42+00:00

<doc> <element> text <item> text1 </item> <item> text2 </item> text3 </element> <element> another text

  • 0
<doc>
 <element>
  text
     <item>
     text1
     </item>
     <item>
     text2
     </item>
  text3
 </element>
 <element>
  another text
 </element>


 ...
</doc>

And I want to extract text to an string like this:

 "text text1 text2 text3"

“item” tags are nested inside “element”

Im using xmlpullparser in Android but I could use any other parser if it make things easier.
tx.

  • 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-30T21:10:43+00:00Added an answer on May 30, 2026 at 9:10 pm

    I parse similar xml files. Here is an example. You’ll need to add error checking as appropriate.

    void loadXML(XmlPullParser xpp) {
        int eventType = xpp.next();
        while (eventType != XmlPullParser.END_DOCUMENT) {
            if (eventType == XmlPullParser.START_TAG && 0 == XML_ELEMENT_TAG.compareTo(xpp.getName())) {
                loadElement(xpp);
            }
    
            eventType = xpp.next();   
        }
    }
    
    private void loadElement(XmlPullParser xpp) {
    
        int eventType = xpp.getEventType();
        if ( eventType == XmlPullParser.START_TAG && 0 == XML_ELEMENT_TAG.compareTo(xpp.getName()) ) {
            eventType = xpp.next();
            while ( eventType != XmlPullParser.END_TAG || 0 != XML_ELEMENT_TAG.compareTo(xpp.getName()) ) {
                if (eventType == XmlPullParser.START_TAG &&     0 == XML_ITEM_TAG.compareTo(xpp.getName())) {
                    loadItem(xpp);
                }
    
                eventType = xpp.next();   
            }
        } 
    }
    
    private void loadItem(XmlPullParser xpp) {
    
        int eventType = xpp.getEventType();
        if ( eventType == XmlPullParser.START_TAG && 0 == XML_ITEM_TAG.compareTo(xpp.getName()) ) {
    
            eventType = xpp.next();
            while ( eventType != XmlPullParser.END_TAG || 0 != XML_ITEM_TAG.compareTo(xpp.getName()) ) {
    
                // Get attributes.
                String  attr = xpp.getAttributeValue(null, XML_MY_ATTR); 
                String  text = null;
    
                // Get item text if present.
                eventType = xpp.next();
                while ( eventType != XmlPullParser.END_TAG || 0 != XML_ITEM_TAG.compareTo(xpp.getName()) ) {
                    if ( eventType == XmlPullParser.TEXT ) {
                        text = xpp.getText();
                    } 
    
                    eventType = xpp.next();
                }
    
                eventType = xpp.next();   
            }
        } 
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to extract meaningful text out of an html document and I was
This is my XML: <?xml version=1.0 encoding=UTF-8?> <?xml-stylesheet href=test_2.xsl type=text/xsl?> <doc xmlns=http://www.foo.org> <div> <title>Mr.
var cityList = from country in doc.Element(result) .Element(cities) .Descendants(city) select new { Name =
I would like to be able to display two lines of text per row
There is HTML page with contents like this. Documentation at MDN says that childNodes
i would like modify text of xml tag value i have used an xml
I have a file which has <Doc> <Text> .... </Text> </Doc> <Doc> <Text> </Text>
I am trying to get the text content of first node in this XML.
I have an XML file formatted like this: <?xml version=1.0 encoding=utf-8?> <Snippets> <Snippet name=abc>
I'm trying to get the elements in an HTML doc that contain the following

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.