Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
12
Task/XML-DOM-serialization/Python/xml-dom-serialization-1.py
Normal file
12
Task/XML-DOM-serialization/Python/xml-dom-serialization-1.py
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
from xml.dom.minidom import getDOMImplementation
|
||||
|
||||
dom = getDOMImplementation()
|
||||
document = dom.createDocument(None, "root", None)
|
||||
|
||||
topElement = document.documentElement
|
||||
firstElement = document.createElement("element")
|
||||
topElement.appendChild(firstElement)
|
||||
textNode = document.createTextNode("Some text here")
|
||||
firstElement.appendChild(textNode)
|
||||
|
||||
xmlString = document.toprettyxml(" " * 4)
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
from xml.etree import ElementTree as et
|
||||
|
||||
root = et.Element("root")
|
||||
et.SubElement(root, "element").text = "Some text here"
|
||||
xmlString = et.tostring(root)
|
||||
Loading…
Add table
Add a link
Reference in a new issue