Hey all,  I recently came across the xml.sax libraries and am trying to
use them.  I am currently making a string variable, and am attempting
to pass it into a parser instance as follows:

 def parseMessage(self, message):
         #create a XML parser
         parser = make_parser()

         #create an instance of our handler class
         #generic, prints out to screen on all events
         dh = docHandler()

         #tell parser to use our handler
         parser.setContentHandler(dh)

         #start it going, will trigger on events as defined in the
docHandler class
         parser.parse(message)
         return

"message" is the following text:
-----------------
<?xml version="1.0" ?>
- <ENVELOPE>
  - <MESSAGE>
      <timestamp>timestamp</timestamp>
    - <COMMAND>
         <SCOPE>asdasd</SCOPE>
         <ACTION>asdasds</ACTION>
      </COMMAND>
    </MESSAGE>
  </ENVELOPE>
---------------


This is dying with the following errors.

File "...../python/lib/python2.4/urllib.py", line 77, in urlopen
    return opener.open(url)
  File "...../python/lib/python2.4/urllib.py", line 180, in open
    return getattr(self, name)(url)
  File "...../python/lib/python2.4/urllib.py", line 409, in open_file
    return self.open_local_file(url)
  File "...../python/lib/python2.4/urllib.py", line 419, in
open_local_file
    raise IOError(e.errno, e.strerror, e.filename)
IOError: [Errno 2] No such file or directory: '?xml version="1.0" ?>\n-
<ENVELOPE>\n  - <MESSAGE>\n      <timestamp>timestamp</timestamp>\n
- <COMMAND>\n         <SCOPE>asdasd</SCOPE>\n
<ACTION>asdasds</ACTION>\n      </COMMAND>\n    </MESSAGE>\n
</ENVELOPE'



So in recap, it looks like it is trying to take my string argument as a
file handler.  How can I get around this?  I would prefer not to make a
bigger footprint on the system by creating a file......


Thanks in advance!
-- 
lucas

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to