Hello! I'm making app which should parse xml file, simple tag like <item> is easy, but i stuck on SAX parser using this method didn't find...

How It Works

Get an answer in three easy steps. Here's how it works...

Ask Your Question

1. Ask Your Question

Enter your smartphone question at the top of this page and click Get An Answer.

Pick Your Priority

2. Pick Your Priority

Tell us how quickly you want your smartphone question answered.

Get An Answer

3. Get An Answer

Connect with your Smartphone tech via online chat or telephone call.

Answer

Customer

Hello!
I'm making app which should parse xml file, simple tag like <item> is easy, but i stuck on SAX parser using this method didn't find requered element:

    item.getChild("media:content").setEndTextElementListener(new EndTextElementListener(){
        public void end(String body) {
            // app never rich this code for somehow...
            currentMessage.setTitle(body);
        }
    });

what i'm doing wrong?

Posted
Alexey Schekin
Smartphone Tech

You need to find description how to read tags in rss root tag:

<rss xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" xmlns:media="http://search.yahoo.com/mrss/">

In your app define Strinf value that contains namespace that you need:

private static final String NS_MEDIA = "http://search.yahoo.com/mrss/";

Inside feedParser make this:

Element media = item.requireChild(NS_MEDIA, "content");

And read content:

media.setStartElementListener(new StartElementListener() {
        public void start(Attributes attrs) {
            if (attrs.getValue(URL).contains("jpg"))
            currentMessage.setImgUrl(attrs.getValue(URL));
        }
    });
Posted
Customer

Thank you very much!

Posted

quoteTestimonialsquote

About ExpertHelp

ExpertHelp is changing the way you connect with service professionals.

Whether you have a quick question while preparing your taxes, troubleshooting a computer problem, or need to hire an attorney, ExpertHelp is the most convenient and affordable way to connect with the right service professional to get the job done.

ExpertHelp has been in business since 2011, is an A+ Rated Better Business Bureau accredited member, and offers a 100% satisfaction guarantee on every question you ask!

More Smartphone Questions...

Ask Your Smartphone Question & Get An Answer Now!