DAGDA SEARCH | Back to results | Support

Learn Python - Python Wiki

Source: https://wiki.python.org/python/getting-started/LearnPython.html

  1. Python Wiki /
  2. Python Wiki /
  3. Getting Started /
  4. Learn Python
View as Markdown

Learn Python

Legacy Wiki Page

This page was migrated from the old MoinMoin-based wiki. Information may be outdated or no longer applicable. For current documentation, see python.org.

Learning python by example

Python XML & XSLT

Create and add elements

from xml.dom.minidom import parseString
doc = parseString(u'<top/>'.encode('UTF-8'))
<?xml version="1.0" ?>
<top/>
top_element=doc.documentElement
element1=doc.createElementNS(None,u'section1')
top_element.appendChild(element1)
element1.appendChild(doc.createElementNS(None,u'subsection1'))
text1=doc.createTextNode(u'My first text')
element1.firstChild.appendChild(text1)
element1.appendChild(doc.createElementNS(None,u'subsection2'))
text2=doc.createTextNode(u'My second text')
element1.lastChild.appendChild(text2)
element1.firstChild.appendChild(text2)
element1.lastChild.appendChild(text1)
PreviousCoding Project Ideas Next Moving to Python from Other Languages