python - Line feed for single tag with mutiline value in Element tree -
i have used element tree in python script generate xml file own tags input.
i need set multiline value single tag in xml file. example,
prj_name = "getcomp" prj_desc = """ level : 3 author : jhon date : 12 may 13 details : ....... .................. .................. """ top = element('projectinfo') kid = subelement(top, 'name') child.text = prj_name kid = subelement(top, 'description') child.text = prj_desc indent(top) # function format xml tags tree = et.elementtree(top) tree.write("myxml.xml") in xml 'description' tag contains mutilline string. if open file in notepad++, able see description tag below,
<projectinfo> <name>compinfo</name> <description> level : 3 author : jhon date : 12 may 13 details : ....... .................. .................. </description> </projectinfo> if open xml file in ie(internet explorer), multiline string 'description' tags displayed in single line below,
<?xml version="1.0"?> -<projectinfo> <name>getcomp</name> <description> level : 3 author : jhon date : 12 may 13 details : ....... .................. .................. </description> </projectinfo> how add together line feed in element tree element multiline value?
to briefly lecture. xml spacing, newlines, tabs , should not rely on styling. xml should vessel transport info , able handle constant re-formatting without losing significance.
that beingness said, want @ to the lowest degree encode newlines transferred independent on how have set in notepad file.
python xml internet-explorer web elementtree
No comments:
Post a Comment