I just don't get it.

Excerpt from my code:

def addElement(doc, name):
    new = et.SubElement(doc, name)
    return new

def addValueElement(doc, name, value):
    new = et.SubElement(doc, name)
    new.text = value
    new.text = '\n'
    return new

doc_header = """<wine></wine>"""
doc = et.XML(doc_header)
addValueElement(xml, u'name', string.strip(dbItem.winename))
addValueElement(xml, u'additionalname', string.strip(dbItem.winename2))
.... more

But the "value" writing to new.text doesn't show up in the xml file.

<wine><name>
</name><additionalname>
</additionalname><vintage><year>
</year><bottle><size>
</size></bottle></vintage></wine>

What am I missing?

By the way is it possible to write the file in a "pretty" format?

One last question (at least for the moment) is how to get something 
along the following lines into the header/beginning of the file:
<?xml version="1.0" encoding="UTF-8"?>
<?jaxfront version=1.60;time=2005-12-18 12:15:07.078;xsd=wineXML.xsd?>
<wine xmlns="http://www.winexml.org/XMLSchema"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; xsi:schemaLocation="
</wine>

I added it to my "doc_header" variable but I can't get it to write 
exactly this.

Thanks
Werner

_______________________________________________
XML-SIG maillist  -  XML-SIG@python.org
http://mail.python.org/mailman/listinfo/xml-sig

Reply via email to