BlackBerry Forums Support Community
              

Closed Thread
 
Thread Tools
Old 07-24-2008, 04:33 PM   #1
christiand
New Member
 
Join Date: Jun 2008
Model: none
PIN: N/A
Carrier: None
Posts: 4
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
skicson
Thumbs Must Hurt
 
Join Date: Mar 2008
Location: Columbia, MD
Model: 8130
PIN: N/A
Carrier: verizon
Posts: 95
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
baran_khan
Thumbs Must Hurt
 
baran_khan's Avatar
 
Join Date: Apr 2008
Model: 9500
PIN: N/A
Carrier: Airtel
Posts: 110
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
christiand
New Member
 
Join Date: Jun 2008
Model: none
PIN: N/A
Carrier: None
Posts: 4
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
baran_khan
Thumbs Must Hurt
 
baran_khan's Avatar
 
Join Date: Apr 2008
Model: 9500
PIN: N/A
Carrier: Airtel
Posts: 110
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



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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


RDP Electronics Transducer Indicator E309 picture

RDP Electronics Transducer Indicator E309

$245.00



New In Box NOVOTECHNIK TLH-0225/TLH 225 Position Transducer picture

New In Box NOVOTECHNIK TLH-0225/TLH 225 Position Transducer

$187.00



Novotechnik TLH-0360 Position Transducer New One Expedited Shipping TLH0360 picture

Novotechnik TLH-0360 Position Transducer New One Expedited Shipping TLH0360

$198.00



AcuAMP DCT500-42-24-F DC Current Transducer, 500A range, 4-20mA output -  USA picture

AcuAMP DCT500-42-24-F DC Current Transducer, 500A range, 4-20mA output - USA

$145.00



Transducer Techniques MDB-10 Load Cell (1 Per order) picture

Transducer Techniques MDB-10 Load Cell (1 Per order)

$135.00



CR Magnetic CR4180-20 True RMS AC Current Transducer 3 Element - New picture

CR Magnetic CR4180-20 True RMS AC Current Transducer 3 Element - New

$199.95







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