html in xml problem
walter hoolwerf
walto at vaag.cx
Thu Sep 26 08:09:34 EDT 2002
Hello,
I need to place some HTML code in an XML file en process it with
python.
The output is a bit weird. I've also used this way to place html code
in XML with flash, worked fine.
as you can see, I already tried replacing the newlines with nothing
(or space), didn't work. The output should be <a> instead of:
<
a
>
My browser wont accept the last.
Who knows? Thanx in advance,
Walto
--------
xml file:
<?xml version="1.0" encoding="iso-8859-1"?>
<HAN>
<info><B>Welcome</B></info>
</HAN>
code:
#!/usr/bin/python2
from xml.dom import minidom, Node
import string
doc = minidom.parseString(open('han.xml').read())
for c in doc.documentElement.childNodes:
if c.nodeType == Node.ELEMENT_NODE:
for d in c.childNodes:
print d.nodeValue.replace("\n", "
").replace("\r", " ")
output:
<
B
>
Welcome
<
/B
>
More information about the Python-list
mailing list