parsing xml data

by jj » Fri, 13 Mar 2009 17:25:46 GMT


Sponsored Links
 Hi everyone

I am trying to parse some data (wrapped in a String), that has xml
format
following is the code that I am using, with no much succes so far :(



    private void parseXml(String str)
    {
        XMLReader myReader=null;

        System.setProperty
("org.xml.sax.driver","org.xmlpull.v1.sax2.Driver");


         try
         {
           myReader = XMLReaderFactory.createXMLReader();
         }
         catch (SAXException e)
         {
                 Log.i("activity","error  = "+e.toString());
         }


        try
        {
                myReader.parse(str);
        }
        catch (IOException e)
        {
                Log.i("activity","error  = "+e.toString());
        }
        catch (SAXException e)
        {
                Log.i("activity","error  = "+e.toString());
                //it fails here!!!
        }

}

when I do myReader.parse(str), I get the following error:
java.io.FileNotFoundException
I guess is because it's trying to acces a file, but what I am trying
to parse is just some data that I have in the String variable, not a
file...

can anybody tell me what I am doing wrong?


Thanks a lot



--~--~---------~--~----~------------~-------~--~----~



parsing xml data

by petunio » Fri, 13 Mar 2009 17:27:11 GMT


 Hi everyone

I am trying to parse some data (wrapped in a String), that has xml
format
following is the code that I am using, with no much succes so far :(

    private void parseXml(String str)
    {
        XMLReader myReader=null;

        System.setProperty
("org.xml.sax.driver","org.xmlpull.v1.sax2.Driver");

         try
         {
           myReader = XMLReaderFactory.createXMLReader();
         }
         catch (SAXException e)
         {
                 Log.i("activity","error  = "+e.toString());
         }

        try
        {
                myReader.parse(str);
        }
        catch (IOException e)
        {
                Log.i("activity","error  = "+e.toString());
        }
        catch (SAXException e)
        {
                Log.i("activity","error  = "+e.toString());
                //it fails here!!!
        }

}

when I do myReader.parse(str), I get the following error:
java.io.FileNotFoundException
I guess is because it's trying to acces a file, but what I am trying
to parse is just some data that I have in the String variable, not a
file...

can anybody tell me what I am doing wrong?

Thanks a lot
--~--~---------~--~----~------------~-------~--~----~


Sponsored Links


parsing xml data

by Pd » Fri, 13 Mar 2009 18:25:12 GMT


 You need either InputSource or URI.

 http://www.saxproject.org/apidoc/org/xml/sax/XMLReader.html 





--~--~---------~--~----~------------~-------~--~----~



parsing xml data

by mafro » Fri, 13 Mar 2009 18:27:47 GMT


 >From the docs:


So the parse() method doesn't accept XML as a String input - it
accepts a path to a file. This is what causes your exception.

Where does your XML come from originally? The SAX parser is designed
to parse directly from a Stream, so wherever your XML is first loaded,
parse it there.

mafro




--~--~---------~--~----~------------~-------~--~----~



parsing xml data

by mafro » Fri, 13 Mar 2009 22:16:00 GMT


 Please don't post in two forums at the same time.. jeez




--~--~---------~--~----~------------~-------~--~----~



Other Threads

1. Error in running DVM test application on linux-x86

Dear All,

I am trying to run the DVM test application on linux-x86 given in the
myandroid/dalvik/tests using the command ./tests/run-test 002

But I am getting following error.

[r...@localhost dalvik]# ./tests/run-test 002
/home/android/dalvik/tests/002-sleep: running...
/home/android/dalvik/tests/002-sleep: FAILED!

#################### info
# Test that Thread.sleep() operates reasonably. This test is actually
# mostly meant as an easy thing to modify in order to test other
things
# in an ad-hoc way.
#################### diffs
--- expected.txt        2009-06-25 00:52:35.000000000 +0530
+++ output.txt  2009-07-06 23:18:38.000000000 +0530
@@ -1,2 +1,2 @@
-Sleeping 1000 msec...
-Done sleeping
+./build: line 27: dx: command not found
+build exit status: 127
####################

files left in /tmp/test-27318
[r...@localhost dalvik]#

Am I missing any thing here.
Whether I need to give the path of dx tool?

Please help.

Regards
Sivan
--~--~---------~--~----~------------~-------~--~----~
unsubscribe: android-porting+unsubscr...@googlegroups.com
website: 

2. No output on the eclipse console

Hi,
When i print any output to the console using System.out.println() or when i
use the Log class for debug, it is not printing on the eclipse console.
I could see the Log class debug message on DDMS monitor console. But not on
the eclipse console. Any idea why?

-- 
Thanks and Regards
Chinnadurai M

--~--~---------~--~----~------------~-------~--~----~

3. info needed on configuring buildbot for android

4. Android code coverage tools

5. Views with round corners and transparent background color

6. How was the conference - man i wanted to go

7. Who is making money in the Android Market?