File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Android and the fly likes Parsing XML <media:content> tag problem. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Mobile » Android
Bookmark "Parsing XML <media:content> tag problem." Watch "Parsing XML <media:content> tag problem." New topic
Author

Parsing XML <media:content> tag problem.

Matt Partner
Greenhorn

Joined: Oct 24, 2012
Posts: 9
Hello to everyone!

First of all I want to thank you all for your great job helping to all people and thanks to you I fixed an old problem few days ago. Thanks!

But now I have a problem parsing for Android an XML document as follows:



My Parser.class is:



This class parse the XML document gived, but I pass the URL through this each other activity called ShowImageActivity where I try to collect using an ARRAY all URL Images from <media:content> tag.



My problem is in the <media:content> tag. I red that I need to use QName class, because these are an especial tags formed by an URI and a LOCALNAME parts.
But I tried to search in Google, here in JavaRanch and I don't find anything to fix this.

Anyone knows how to use it to parse an XML in Java? I'm very new in Java and Android but I'll thank it to you if you can help to me. If you need anything mor,e please tell it to me.

Thanks!
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42912
    
  68
If you only need the <media:content> nodes then I would use XPath (which has been available since Android 2.2 via the javax.xml.xpath package).
Matt Partner
Greenhorn

Joined: Oct 24, 2012
Posts: 9
I'm using a code found in www.javabeat.net using XPATH:

This is te class who reads the XML File passed:



And this the activity where I try to pass the URL and get some values. But I don't understand if lacks anything or what happenned, because the result in the LOG output is NULL:



Any idea? Thanks! I have been working with it all weekend but I don't how to continue...



Matt Partner
Greenhorn

Joined: Oct 24, 2012
Posts: 9
Ok now I have been reading and working with XPath and finally I work with only one file class: ShowImageActivity.class

But I try to parse <media:content> tag with this:



But any text appears in the Log.v() and in the LOGCAT log says to me that can't open file because ENAMETOOLONG and the problem is focused in the InputSource object.

Thanks for your help and patience, any ideas? Thanks!

Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42912
    
  68
Please post the entire stack trace, and in which line of code it occurs.

I would start by getting this to work in a standalone app rather than as part of an Android app - that's likely much easier to debug.
Matt Partner
Greenhorn

Joined: Oct 24, 2012
Posts: 9
Sure, here I let the LOGCAT trace (sorry I forgot to post in the last reply):



I wrote the error in in black at line 98.
02-06 19:16:23.976: W/System.err(671): : open failed: ENAMETOOLONG (File name too long)

I don't know how to fix this problem. Thanks for your help Ulf Dittmer!
Matt Partner
Greenhorn

Joined: Oct 24, 2012
Posts: 9
I still working with it but I am not able to fix this bug... if anyone like Ulf can help me, I'll be very grateful with him or her.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18987
    
    8

You should look at the code which is throwing the exception. From the stack trace:



In your onCreate() method you have code at line 61 which looks like



The stack trace tells us that. And all of the dozens of lines above that in the stack trace tell us that you passed the contents of an XML document as the file name, rather than the name of a file.

You haven't shown us any code containing that onCreate() method, but anyway that's where you should look.


Matt Partner
Greenhorn

Joined: Oct 24, 2012
Posts: 9
I'm going to try to fix it focusing in the point you told me.

Thanks for your effort, Paul
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Parsing XML <media:content> tag problem.