import csv import xml.etree.ElementTree as ET import sys import os csv_file = '/home/x79/sisvietnamvn_01/sisvietnamvn_Trang chính thức hiện tại/DS_BacSi/DANH SÁCH BÁC SĨ NGỒI PHÒNG KHÁM_THÔNG TIN CHI TIẾT_FULL.csv' xml_file = '/home/x79/sisvietnamvn_01/sisvietnamvn_Trang chính thức hiện tại/DS_BacSi/bnhvinakhoaquctsiscnth.WordPress.2026-07-28 (5).xml' print("CSV Headers:") with open(csv_file, 'r', encoding='utf-8-sig') as f: reader = csv.reader(f) print(next(reader)) print("\nXML meta keys for first doctor:") tree = ET.parse(xml_file) root = tree.getroot() ns = { 'wp': 'http://wordpress.org/export/1.2/', 'content': 'http://purl.org/rss/1.0/modules/content/' } for channel in root.findall('channel'): for item in channel.findall('item'): post_type = item.find('wp:post_type', ns) if post_type is not None and post_type.text == 'doctor': print('Title:', item.find('title').text) for meta in item.findall('wp:postmeta', ns): key = meta.find('wp:meta_key', ns) val = meta.find('wp:meta_value', ns) if key is not None and val is not None and not key.text.startswith('_'): print(f" {key.text}") break # Count doctors in each print(f"\nTotal items in XML:") c = 0 for channel in root.findall('channel'): for item in channel.findall('item'): post_type = item.find('wp:post_type', ns) if post_type is not None and post_type.text == 'doctor': c += 1 print(c)