busting-out XML sections

Thomas Gagne tgagne at ix.netcom.com
Sat Oct 7 00:59:19 EDT 2000


I forgot the attachment...

--
.tom


-------------- next part --------------
#!/usr/bin/env python
import sys
from string import *
from IsdIO import *

def main():
	if len(sys.argv) == 3:

		tagname = sys.argv[1]
		batchfile = sys.argv[2]

		isdIO = IsdIO()
		s = isdIO.login(None, tagname, 2)

		startElement = "<%s>" % (tagname,)
		endElement   = "</%s>" % (tagname,)

		porder = ""
		copying = 0

		fp = open(batchfile, "r")
		if fp:
			while 1 == 1:
				data = fp.readline()
				if data:
					if strip(data) == startElement:
						copying = 1
				
					if copying:
						porder = porder + data
				
					if strip(data) == endElement:
						copying = 0
						bytes = isdIO.send(porder)
						if bytes > 0:
							m = IsdMessage()
							response = ""
							while 1 == 1:
								rc = m.get(isdIO)
								if rc > 0:
									response = response + m.message
								if m.header.member('more') == 0:
									break

							print response
						porder = ""
				else:
					break
		fp.close()

	else:
		print "usage: %s tag pathname\n" % (sys.argv[0],)

if __name__ == '__main__':
	main()


More information about the Python-list mailing list