Parsing XML data in a string using SAX Parser.

Put your problem here if it does not fit any of the other categories.

Parsing XML data in a string using SAX Parser.

Postby kiran » Fri Mar 14, 2008 10:02 am

Hi,
How can we use a SAX Parser to parse XML data that is stored in a string. The string holds XML data something like
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. String xdata = "<firsttag><secondtag>Hello</secondtag></firsttag>"
Parsed in 0.031 seconds, using GeSHi 1.0.8.4
Can this be parsed using SAXParser?
Thanks in advance.
:) smile it is the key that fits the lock of everybody's heart
User avatar
kiran
Experienced Developer
Experienced Developer
 
Posts: 78
Joined: Thu Nov 22, 2007 11:36 am
Location: India

Top

Postby res » Sat Mar 15, 2008 10:51 pm

parsing_xml_from_the_net_-_using_the_saxparser-t353.html

Parsing XML data using the SAXParser tutorial.
res
Senior Developer
Senior Developer
 
Posts: 146
Joined: Tue Nov 20, 2007 8:14 pm
Location: United States

Postby kiran » Sun Mar 16, 2008 12:36 pm

Hi, thanks res.
But I have already gone through that tutorial and was able to parse from net and from a file. I get xml as response to a http post and store this in a string. I couldnt parse the data directly from the string. Currently i am saving this string to a file in the device and then parsing this file to get the data. I wanted to know whether i could parse the data in the string directly.

Thanks & Regards,
Kiran
:) smile it is the key that fits the lock of everybody's heart
User avatar
kiran
Experienced Developer
Experienced Developer
 
Posts: 78
Joined: Thu Nov 22, 2007 11:36 am
Location: India

Postby Ted Hopp » Mon Mar 31, 2008 7:46 am

Turn your string into an input source:

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. parser.parse(new InputSource(new StringReader(string)), handler);
Parsed in 0.031 seconds, using GeSHi 1.0.8.4
Ted Hopp
Ted Hopp
Freshman
Freshman
 
Posts: 5
Joined: Fri Jan 18, 2008 5:56 pm

Postby kiran » Mon Mar 31, 2008 7:59 am

Hi,
Thanks Ted Hopp. It works. :D
Regards,
Kiran
:) smile it is the key that fits the lock of everybody's heart
User avatar
kiran
Experienced Developer
Experienced Developer
 
Posts: 78
Joined: Thu Nov 22, 2007 11:36 am
Location: India

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: No registered users and 15 guests