I am trying to define an XML ENTITY that contains only a newline character (
 ;). But unfortunalty this does not seem to be working:
<?xml version="1.0"?>
<!DOCTYPE my_doc [
<!ENTITY newline " ">
]>
<root attr="hello &newline; world !!!" attr1="hello world !!!" ></root>
In the example above I expect the attributes attr and attr1 to have the same value. But in case of 'attr' the entity 'newline' is replaced with a space by parsers:
attr => hello world !!!
attr1 => hello
world !!!
I am using python to parse this, but I do not think that this is relevant:
import xml.etree.ElementTree as ET
data_as_string = """<?xml version="1.0"?>
<!DOCTYPE my_doc [
<!ENTITY newline " ">
]>
<root attr="hello &newline; world !!!" attr1="hello world !!!" ></root>
"""
root = ET.fromstring(data_as_string)
print root
print root.attrib
for k,v in root.attrib.items():
print "%s => %s" % (k, v)
Does know a solution for this?
Thanks, Gerald