Экспорт:
Папки
/root/polzovateli/var_null/yaziki-programmirovaniya/python/XML-modifikaciya/lxml
Не экспортировать закрытые директории
Преобразовывать заметки в html
Экспортировать
Применить |
| 2014-12-11 15:55:08 |
el_xml.remove(child_xml)
Похожие разделы:
->var_null:root/Пользователи/var_null/Языки программирования/python/XML Модификация/lxml/ (текущий раздел)
| 2014-12-03 16:21:25 |
path_header = data['source'] + "/" + data['etalon_dir_parser'] + "/_header.xml"; path_header_tmp = data['source'] + "/" + data['etalon_dir_parser'] + "/_header_tmp.xml"; tree = etree.parse(path_header) root = tree.getroot() for child in root: #print child.tag, child.attrib if(child.tag == "acc_obj"): acc_obj = child add = etree.Element("created_by") add.attrib['n']='1' acc_obj.append(add) xml_string = etree.tostring(tree, encoding="utf-8", method="xml") my_file = open(path_header_tmp, 'w') my_file.write(xml_string)
| 2014-12-03 15:34:27 |
from lxml import etree file_header_tmp = open(path_header_tmp, 'a') content_tpl = "" file = open(path_header) #открываем файл for line in file.readlines(): content_tpl += line print(content_tpl) root = etree.fromstring(content_tpl) for child in root: print child.tag, child.attrib if(child.tag == "my_el"): add = etree.Element("add_el") child.append(add) xml_string = etree.tostring(root, encoding="utf-8", method="xml") my_file = open(path_header_tmp, 'w') my_file.write(xml_string)