Revision 4757
Added by Aaron Marcuse-Kubitza over 12 years ago
lib/xml_dom.py | ||
---|---|---|
37 | 37 |
def replace(old, new): |
38 | 38 |
'''@param new Node|None''' |
39 | 39 |
assert old.parentNode != None # not removed from parent tree |
40 |
if new == None: new = [] |
|
40 |
if new == None: new = []
|
|
41 | 41 |
else: new = lists.mk_seq(new) |
42 | 42 |
|
43 | 43 |
olds_parent = old.parentNode |
... | ... | |
58 | 58 |
@return The *new* node |
59 | 59 |
''' |
60 | 60 |
if isinstance(new, bool): new = bool2str(new) |
61 |
elif isinstance(new, int) or isinstance(new, float): new = str(new) |
|
61 | 62 |
if util.is_str(new): new = node.ownerDocument.createTextNode(new) |
62 | 63 |
replace(node, new) |
63 | 64 |
return new |
Also available in: Unified diff
xml_dom.py: replace_with_text(): Support ints and floats