Closed kenahoo closed 5 years ago
Hi there,
I think this could work.
def build(textBlock):
"""
builds the html
"""
doc, tag, text = Doc().tagtext()
doc.asis(textBlock)
return doc.getvalue()
xmlBlock = "<?xml version="1.0" encoding="UTF-8"?>"
build(xmlBlock)
The 'asis' method basically means it will take the variable in as it comes.
Let me know if this works.
@jacobluke121: while it's true that the asis
method should be used here, your example looks like it would always return the same string (just the XML declaration).
@kenahoo: so, yes, use the asis
method. There's an example in the tutorial about adding a HTML doctype, and it's the same for XML declarations: https://www.yattag.org/#appending-strings-as-is
Okay, thanks. I was hoping for something that would let me avoid remembering the declaration syntax every time I write a document, but this does work.
@leforestier thanks for pointing this out. This makes sense.
Is there a way to add a declaration at the top of an XML document I'm generating, e.g.
<?xml version="1.0" encoding="UTF-8"?>
?