CARVIEW |
Select Language
HTTP/2 302
server: nginx
date: Wed, 30 Jul 2025 18:02:58 GMT
content-type: text/plain; charset=utf-8
content-length: 0
x-archive-redirect-reason: found capture at 20110812075349
location: https://web.archive.org/web/20110812075349/https://wiki.python.org/moin/LearnPython
server-timing: captures_list;dur=0.551749, exclusion.robots;dur=0.020992, exclusion.robots.policy;dur=0.009701, esindex;dur=0.009475, cdx.remote;dur=84.438575, LoadShardBlock;dur=97.063234, PetaboxLoader3.datanode;dur=55.208886
x-app-server: wwwb-app216
x-ts: 302
x-tr: 208
server-timing: TR;dur=0,Tw;dur=0,Tc;dur=0
set-cookie: SERVER=wwwb-app216; path=/
x-location: All
x-rl: 0
x-na: 0
x-page-cache: MISS
server-timing: MISS
x-nid: DigitalOcean
referrer-policy: no-referrer-when-downgrade
permissions-policy: interest-cohort=()
HTTP/2 200
server: nginx
date: Wed, 30 Jul 2025 18:03:00 GMT
content-type: text/html; charset=utf-8
x-archive-orig-date: Fri, 12 Aug 2011 07:53:49 GMT
x-archive-orig-server: Apache/2.2.16 (Debian)
x-archive-orig-vary: Cookie,User-Agent,Accept-Language
x-archive-orig-set-cookie: MOIN_SESSION_80_ROOT_moin=f0ac3a23e598ba6f30e2177090fa148d28d8b913; expires=Fri, 12-Aug-2011 08:53:00 GMT; Max-Age=3600; Path=/
x-archive-orig-content-length: 11967
x-archive-orig-connection: close
x-archive-guessed-content-type: text/html
x-archive-guessed-charset: utf-8
memento-datetime: Fri, 12 Aug 2011 07:53:49 GMT
link: ; rel="original", ; rel="timemap"; type="application/link-format", ; rel="timegate", ; rel="first memento"; datetime="Sat, 08 Dec 2007 11:21:01 GMT", ; rel="prev memento"; datetime="Sat, 08 Dec 2007 11:21:01 GMT", ; rel="memento"; datetime="Fri, 12 Aug 2011 07:53:49 GMT", ; rel="next memento"; datetime="Sat, 09 Jul 2022 12:44:38 GMT", ; rel="last memento"; datetime="Sat, 20 Jul 2024 22:48:35 GMT"
content-security-policy: default-src 'self' 'unsafe-eval' 'unsafe-inline' data: blob: archive.org web.archive.org web-static.archive.org wayback-api.archive.org athena.archive.org analytics.archive.org pragma.archivelab.org wwwb-events.archive.org
x-archive-src: WPO-20110812072219-crawl438/WPO-20110812074858-01703.warc.gz
server-timing: captures_list;dur=0.921443, exclusion.robots;dur=0.023613, exclusion.robots.policy;dur=0.011368, esindex;dur=0.012347, cdx.remote;dur=737.892298, LoadShardBlock;dur=264.836991, PetaboxLoader3.datanode;dur=326.197438, load_resource;dur=211.636744, PetaboxLoader3.resolve;dur=78.800833
x-app-server: wwwb-app216
x-ts: 200
x-tr: 1273
server-timing: TR;dur=0,Tw;dur=0,Tc;dur=0
x-location: All
x-rl: 0
x-na: 0
x-page-cache: MISS
server-timing: MISS
x-nid: DigitalOcean
referrer-policy: no-referrer-when-downgrade
permissions-policy: interest-cohort=()
content-encoding: gzip
LearnPython - PythonInfo Wiki
User
Learning python by example
Contents
Python XML & XSLT
Create and add elements
from xml.dom.minidom import parseString
- creating new document, and root element at the same time.
doc = parseString(u'<top/>'.encode('UTF-8'))
- print doc.toprettyxml() will show you how it looks
- this would create:
<?xml version="1.0" ?> <top/>
Now we reference to our <top/> element by:
top_element=doc.documentElement
- We create another element by:
element1=doc.createElementNS(None,u'section1')
- Add it under our top element by:
top_element.appendChild(element1)
- Create another element and add it under element1
element1.appendChild(doc.createElementNS(None,u'subsection1'))
- How to create a text node:
text1=doc.createTextNode(u'My first text')
- Since we have no reference to subsection1. We start at reference to element1
element1.firstChild.appendChild(text1)
- add second subelement:
element1.appendChild(doc.createElementNS(None,u'subsection2'))
- create next text element, and add it to subsection2
text2=doc.createTextNode(u'My second text') element1.lastChild.appendChild(text2)
- We are working with references. To switch text in subsections, you could do:
element1.firstChild.appendChild(text2) element1.lastChild.appendChild(text1)
LearnPython (last edited 2008-11-15 13:59:36 by localhost)