CARVIEW |
Select Language
HTTP/2 302
server: nginx
date: Thu, 24 Jul 2025 23:34:06 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.549709, exclusion.robots;dur=0.022328, exclusion.robots.policy;dur=0.012094, esindex;dur=0.011317, cdx.remote;dur=42.789502, LoadShardBlock;dur=384.529192, PetaboxLoader3.datanode;dur=148.883384, PetaboxLoader3.resolve;dur=195.619272
x-app-server: wwwb-app221
x-ts: 302
x-tr: 456
server-timing: TR;dur=0,Tw;dur=0,Tc;dur=0
set-cookie: SERVER=wwwb-app221; 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: Thu, 24 Jul 2025 23:34:07 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.507293, exclusion.robots;dur=0.020379, exclusion.robots.policy;dur=0.010397, esindex;dur=0.011563, cdx.remote;dur=12.176486, LoadShardBlock;dur=256.996866, PetaboxLoader3.datanode;dur=130.476488, PetaboxLoader3.resolve;dur=194.673246, load_resource;dur=108.222587
x-app-server: wwwb-app221
x-ts: 200
x-tr: 418
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)