I got python 2.6 which has an old version of toprettyxml() which doesn't do my xml formatting as expected. Hence Im trying to call xmllint using subprocess. This is my simplified code.
xmlParseCmd = "xmllint -format - <<< '%s'" % '<?xml version="1.0" encoding="UTF-8"?> <insertion> <mytag>123456</mytag> <mytag2>789</mytag2> </insertion>'
print shlex.split(xmlParseCmd)
pxmlParser = subprocess.Popen(shlex.split(xmlParseCmd), stdout=subprocess.PIPE)
pretty_xml = pxmlParser.communicate()[0]
print pretty_xml
The program hangs indefinitely after the below output. I guess its waiting for some input.
-> python ~/myscripts/resources/test_xtract.py
['xmllint', '-format', '-', '<<<', '<?xml version="1.0" encoding="UTF-8"?> <insertion> <mytag>123456</mytag> <mytag2>789</mytag2> </insertion>']
I've used a here string as input for xmllint, then why is it still waiting for input? I've being trying to debug this but havnt found anything concrete to solve this. Any pointers would be of great help