BlackBerry Forums Support Community               

Closed Thread
 
LinkBack Thread Tools
Old 07-24-2008, 04:33 PM   #1 (permalink)
New Member
 
Join Date: Jun 2008
Model: none
PIN: N/A
Carrier: None
Posts: 4
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default I can parse xml, but how to export data? (outside handler)

Please Login to Remove!

If the title is too brief...

With the help of these forums (in particular richard.pluckett and jfisher's responses) I successfully parsed an xml file received through an http request.

SAXParserFactory spf = SAXParserFactory.newInstance();
SAXParser parser = spf.newSAXParser();
MySAXHandler handler = new MySAXHandler();
parser.parse(inputstream, handler);

Now the handler I wrote parses it all properly, however I don't understand how to save this data. I have the handler class creating other objects to hold this data once the entire document has been read, but I don't see how to logically access these objects once the parse method is over. They're just floating around in memory with no way to reference them.

I hope expressed my need properly, let me know if you want a detailed explanation other than "what do I do with the xml data I just parsed so that the rest of my application has complete access to it".


Thanks,

Christian.
Offline  
Old 07-24-2008, 11:31 PM   #2 (permalink)
Thumbs Must Hurt
 
Join Date: Mar 2008
Location: Columbia, MD
Model: 8130
PIN: N/A
Carrier: verizon
Posts: 95
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Something besides just adding your own method into the handler? Ex:

MySAXHander extends blahblahblah

public Object getData()
{
return data;
}

==

Once you have it out of the handler, you can look at the docs for PersistantObject storage of data. It's pretty straightforward.


(It's late so perhaps I'm not understanding the question).

Quote:
Originally Posted by christiand View Post
If the title is too brief...

With the help of these forums (in particular richard.pluckett and jfisher's responses) I successfully parsed an xml file received through an http request.

SAXParserFactory spf = SAXParserFactory.newInstance();
SAXParser parser = spf.newSAXParser();
MySAXHandler handler = new MySAXHandler();
parser.parse(inputstream, handler);

Now the handler I wrote parses it all properly, however I don't understand how to save this data. I have the handler class creating other objects to hold this data once the entire document has been read, but I don't see how to logically access these objects once the parse method is over. They're just floating around in memory with no way to reference them.

I hope expressed my need properly, let me know if you want a detailed explanation other than "what do I do with the xml data I just parsed so that the rest of my application has complete access to it".


Thanks,

Christian.
Offline  
Old 07-25-2008, 12:09 AM   #3 (permalink)
Thumbs Must Hurt
 
baran_khan's Avatar
 
Join Date: Apr 2008
Model: 9500
PIN: N/A
Carrier: Airtel
Posts: 110
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

In case, if you don't want to use the persistent storage ...another option is to have the parser itself in your functioning class..i.e use ur class both for the process execution and along with that declare the handler in the class itself..that will allow you to assign the values to the variables declared in the class and can be used as and when required...

Second approach would be to create static variables in the main class and assign them the values...although that would not be a great approach but certainly solve ur purpose....

Hope it helps!!!
__________________
Smart People ask for Help!!!
Offline  
Old 07-25-2008, 12:48 PM   #4 (permalink)
New Member
 
Join Date: Jun 2008
Model: none
PIN: N/A
Carrier: None
Posts: 4
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for the responses.

The static variable works and is a quick fix in the meantime. I was trying to do this but my 2 weeks worth of self-explored Java skills are obviously poor heh.

I'll eventually need the persistent storage elsewhere, so when I get to that I'll knock both birds with one stone.

Thanks again, it helped.

Christian
Offline  
Old 07-26-2008, 01:00 AM   #5 (permalink)
Thumbs Must Hurt
 
baran_khan's Avatar
 
Join Date: Apr 2008
Model: 9500
PIN: N/A
Carrier: Airtel
Posts: 110
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by christiand View Post
Thanks for the responses.

The static variable works and is a quick fix in the meantime. I was trying to do this but my 2 weeks worth of self-explored Java skills are obviously poor heh.

I'll eventually need the persistent storage elsewhere, so when I get to that I'll knock both birds with one stone.

Thanks again, it helped.

Christian
welcome....
__________________
Smart People ask for Help!!!
Offline  
Closed Thread


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On





Copyright 2004-2014 BlackBerryForums.com.
The names RIM and BlackBerry are registered Trademarks of BlackBerry Inc.