Xml-файлове като или отвори

Примерен код

1
0

как да отворите дърво на xml-файла

import xml.etree.ElementTree as ET

tree = ET.parse('filename.xml') #this gets the file into a tree structure
tree_root = tree.getroot() #this gives us the root element of the file
-1
0

като чете xml файл

import xmltodict as xtd
import os

xml_file_content = ""

catalog_dir = os.chdir('directory')
catalog_dir_array = os.listdir(catalog_dir)

if("nameOfFile.xml" in catalog_dir_array):
    catalog_file_content = open("nameOfFile.xml", "r").read()

catalog_file_content_dict = xtd.parse(catalog_file_content)

Подобни страници

Подобни страници с примери

На други езици

Тази страница на други езици

Русский
..................................................................................................................
English
..................................................................................................................
Italiano
..................................................................................................................
Polski
..................................................................................................................
Română
..................................................................................................................
한국어
..................................................................................................................
हिन्दी
..................................................................................................................
Français
..................................................................................................................
Türk
..................................................................................................................
Česk
..................................................................................................................
Português
..................................................................................................................
ไทย
..................................................................................................................
中文
..................................................................................................................
Español
..................................................................................................................
Slovenský
..................................................................................................................
Íslensk
..................................................................................................................