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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T05:35:40+00:00 2026-06-14T05:35:40+00:00

I made a webservice in java with a method that returns a string (a

  • 0

I made a webservice in java with a method that returns a string (a generic list in XML format). I consume this webservice from Android, and I get this string, but after several tries the Android emulator just crashes when trying to deserialize the string. This is an example for the string I get:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<peliculas>
    <pelicula>
        <id>18329</id>
        <poster>http://cache-cmx.netmx.mx/image/muestras/5368.rrr.jpg</poster>
        <titulo>007 Operaci&amp;oacute;n Skyfall</titulo>
    </pelicula>
...
</peliculas>

This is the class in the webservice:

@XmlRootElement
public class Peliculas{

    @XmlElement(name="pelicula")
    protected List<Pelicula> peliculas;
    public Peliculas(){ peliculas = new ArrayList<Pelicula>();}

    public Peliculas(List<Pelicula> pe){
        peliculas = pe;
    }


    public List<Pelicula> getList(){
        return peliculas;       
    }

    public void add(Pelicula pelicula) {
        peliculas.add(pelicula);
    }
}

________EDIT______________

Seems like you can’t use JAXB with Android, and there’s better/lighter libraries for that. so I tried Simple XML. This is the method:

public Peliculas unmarshal(String xml) throws Exception{            
    Peliculas peliculas = new Peliculas();  
    Serializer serializer = new Persister();
    StringBuffer xmlStr = new StringBuffer( xml );
    peliculas = serializer.read(Peliculas.class, ( new StringReader( xmlStr.toString() ) )  );
    return peliculas;
}

BUT I get this exception, seems like it can’t save data in object:

11-12 20:30:10.898: I/Error(1058): Element 'Pelicula' does not have a match in class app.cinemexservice.Pelicula at line 3
  • 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-14T05:35:41+00:00Added an answer on June 14, 2026 at 5:35 am

    I used SAX to parse the file, and then convert it manually to an object. This is the code:

    public List<Pelicula> unmarshal(String xml) throws Exception{           
            List<Pelicula> peliculas = new ArrayList<Pelicula>();       
            InputStream is = new ByteArrayInputStream(xml.getBytes("UTF-8"));
            XmlPullParser parser = Xml.newPullParser(); 
            char[] c;
            String id="", titulo="", poster="", atributo="";
            int datos =0;
            try{ 
                parser.setInput(is, "UTF-8"); 
                int event = parser.next();  
            while(event != XmlPullParser.END_DOCUMENT) { 
                if(event == XmlPullParser.START_TAG) { 
                    Log.d(TAG, "<"+ parser.getName() + ">"); 
                    atributo = parser.getName();
                    for(int i = 0; i < parser.getAttributeCount(); i++) { 
                        Log.d(TAG, "\t"+ parser.getAttributeName(i) + " = "+ parser.getAttributeValue(i)); 
                    } 
                } 
                if(event == XmlPullParser.TEXT&& parser.getText().trim().length() != 0) 
                {
                    Log.d(TAG, "\t\t"+ parser.getText());
                    if (atributo=="id"){id=parser.getText(); datos++;}
                    else if(atributo=="titulo"){titulo=parser.getText(); datos++;}
                    else if(atributo=="poster"){poster=parser.getText(); datos++;}
                    if(datos==3){peliculas.add(new Pelicula(id, titulo, poster)); datos=0;} 
                }
                    if(event == XmlPullParser.END_TAG) 
                        Log.d(TAG, "</"+ parser.getName() + ">");               
                    event = parser.next(); 
    
                is.close();
            }
            } catch(Exception e) { Toast.makeText(this, e.getMessage(), Toast.LENGTH_LONG).show(); }        
            for (Pelicula p : peliculas){
                Log.d("Película en lista: ", p.titulo);
            }           
            return peliculas;
        }
    

    It’s way too long for my taste, but I just couldn’t figure out Simple XML to match my classes.

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

Sidebar

Related Questions

I made an iphone app to capture image from camera and to set that
I am new to using .net 4.0 VS2010. I need to consume java webservice
I'm planning an XML web service that takes an XML request and returns an
Returning information from webservice. I have made a class for the return object. But
In Android I want to call webservice which is made into php with Json
When i generate a webservice from my DAO in RAD it creates a Helper.java,
I made a Webservice Operation whose return type is STRING [] Following is the
I've made .NET web service, so far my android application can communicate with my
I made a WPF example that consumes a web service ( www.webservicex.com/globalweather.asmx ) in
I made an android application which connects to a local web service on my

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.