June 2000
Intermediate to advanced
556 pages
8h 45m
English
Routing the XML file through xmln and picking up the output is made easy by Python's popen function, which can be found in the os module. You simply provide it with the command you want executed and it returns a file object. By reading from this file object, you read the output of the executed command.
CD-ROM reference=8004.txt >>> import os >>> f = os.popen ("xmln greeting.xml") >>> f.readlines() ['(greeting\012', 'Aquality WARM\012', '-\\n\012', '-A greeting from greeting-land.\012', '-\\n\012', '?greeting x=1\012', '-\\n\012', ')greeting\012'] >>> f.close()
In the code above, the popen function creates a “pipe” connection to the output of the command xmln greeting.xml. The full output is read in one go by the ...
Read now
Unlock full access