It's not a secret anymore!*
The moose likes XML and Related Technologies and the fly likes Problems Parsing an  XML file - Need Help. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Problems Parsing an  XML file - Need Help." Watch "Problems Parsing an  XML file - Need Help." New topic
Author

Problems Parsing an XML file - Need Help.

Wolfgang Obi
Ranch Hand

Joined: Dec 05, 2005
Posts: 134
hello can someone maybe help me here... i've been trying to parse an XML document.

in my "loadServerValues" method, a connection is made with a URL (a content server, which hosts an XML format list(see excerpt below)..

the received data is the parsed with help of the "IndexParser" class....
and the data is in turn displayed in an SWT table. Each line in the table is a representation of a "TorrentEntry" object.




this is my "loadServerValues" method:



this is my IndexParser Class:



and this is my TorrentEntry class:


i have a table, in which i have a button which calls up the "loadServerValues" method like this:



and here's the output:


RETREIVING CONTENT DATA!

contents are:
<?xml version="1.0" encoding="ISO-8859-1" ?>
- <contentindex>
<service>*****</service>
- <entry type="torrent">
<torrentId>1</torrentId>
<title>blah1</title>...etc etc
.... </entry>

Hashtable contents: 0 [as you can see this hashtable has a size of "0")

the data can be retreived as a String representation, but for some reason the parsing obviously isnt going ahead as planned.
why is this not working?

am i making some syntax errors or is there something i'm missing here?

thank you.
[ November 12, 2007: Message edited by: Wolfgang Obi ]
Wolfgang Obi
Ranch Hand

Joined: Dec 05, 2005
Posts: 134
hi,
still need help here.
can anyone help me with this?
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41178
    
  45
That's a lot of code and XML you posted, and it's not even using CODE tags to keep it formatted. I think it's too much to expect that soemone would go through all that, when there isn't even much in the way of problem description. What is the code supposed to do? What does it do now? Where does it go wrong? TellTheDetails


Ping & DNS - my free Android networking tools app
Wolfgang Obi
Ranch Hand

Joined: Dec 05, 2005
Posts: 134
Originally posted by Ulf Dittmer:
That's a lot of code and XML you posted, and it's not even using CODE tags to keep it formatted. I think it's too much to expect that soemone would go through all that, when there isn't even much in the way of problem description. What is the code supposed to do? What does it do now? Where does it go wrong? TellTheDetails



okay, one sec let me re edit and repost.
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12761
    
    5


The parse routine discards exceptions that will tell you what is happening.



Im betting an exception is thrown very early.

Bill
Wolfgang Obi
Ranch Hand

Joined: Dec 05, 2005
Posts: 134
Originally posted by William Brogden:


The parse routine discards exceptions that will tell you what is happening.



Im betting an exception is thrown very early.

Bill


wow! how could i have over looked that? 'preciate it.

well, i corrected that and an exception was thrown pointing to this line in the IndexParser class:



everything seems done correctly,but i still seem to be missing something.
what part of this code is producing the error?
[ November 13, 2007: Message edited by: Wolfgang Obi ]
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12761
    
    5


I have to tell you that I REALLY hate to use code like that for exactly the problem you are having. I would do this is steps with verification/debugging output like.

payload = payload.trim()
System.out.printline("trimed payload is " + payload.size() );
byte[] buf = payload.getBytes()
System.out.printline("Resulting bytes " + buf.length + " in length" )
etc...

Bill
Wolfgang Obi
Ranch Hand

Joined: Dec 05, 2005
Posts: 134
okay, for anyone who's interested:

i was parsing wrongly:



i was supposed to be getting the content corresponding to the qualified name and not the value of the attributes ("attrs") as i was doing above.

i wonder what i was thinking.

-W.O.
 
wood burning stoves
 
subject: Problems Parsing an XML file - Need Help.
 
Similar Threads
javax xml parsers FactoryConfigurationError
XML to HashMap......
parse content:encode
java code and SAX
Editor Application with Interpreter pattern