File: xmlutils.py

package info (click to toggle)
kaa-base 0.6.0%2Bsvn4596-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd, stretch, wheezy
  • size: 2,348 kB
  • ctags: 3,068
  • sloc: python: 11,094; ansic: 1,862; makefile: 74
file content (36 lines) | stat: -rw-r--r-- 644 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import sys
from kaa import xml

x = xml.Document(sys.argv[1], 'freevo')

for c in x.children:
    print c.name, c.type, c.parent.name
print

for c in x:
    print c.name, c.type
print

for c in x.children:
    if c.name == 'movie':
        print 'title is', c.getattr('title')
        for y in c.get_child('info').children:
            print y.name, y.content, type(y.content)
print
        


x = xml.Document(root='freevo')

c = xml.Node('foo')
c.content = "hallo"

x.add_child(c)
x.add_child('foo').add_child('x')
x.add_child('bar', 'text')
x.add_child('hi', x='y').setattr('7', 7)
x.add_child('last', 'text', x='y')

print x

x.save('foo')