File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Parsing XML <media:content> tag problem.

 
Matt Partner
Greenhorn
Posts: 9
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Pie
Posts: 42966
73
  • 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 9
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 9
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Pie
Posts: 42966
73
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 9
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 9
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Pie
Posts: 20206
26
MySQL Database
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 9
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic