Python如何将特定值导出到XML?

问题描述 投票:0回答:0

大家早上好,

我是论坛的新人,我是一家处理危险工业废物的跨国公司的法国网络安全技术员,我需要你的帮助:

我们使用 Bitdefender Antivirus,需要每天检索有关恶意软件签名更新的数据。 Bitdefender 使用特定的 shell,我们设法在 .bat 中创建了一个脚本,该脚本创建了一个包含值的 .txt 文件,然后我创建了一个 python 程序,它只提取所需的值,并创建了一个我希望值出现的 XML 文件:

enter image description here

[编辑]:下面是python代码=>

ti = 0
thetai = 0
with open ("Bitdefender.GUSav.txt", "r") as fichierTexte:
    for index, l in enumerate(fichierTexte):
        donnee=[str(d) for d in l.split(": ")]
        if index == 1:
            thetai = float(donnee[1].strip())
            break
        else:
            ti = float(donnee[1].strip())

print(ti)
print(thetai)

from xml.dom import minidom
import os 
    
root = minidom.Document()
  
xml = root.createElement('root') 
root.appendChild(xml)
  
productChild = root.createElement('Mise à jour')
productChild.setAttribute('bases AV Bitdefender:', 'ti and thetai I want to put here, with comma separated or break to the line if possible')
  
xml.appendChild(productChild)
  
xml_str = root.toprettyxml(indent ="\t") 
  
save_path_file = "MAJ.Bases.Bitdefender.xml"
  
with open(save_path_file, "w") as f:
    f.write(xml_str) 

谢谢你的帮助,

祝你有美好的一天,

致以诚挚的问候, 乔纳森

我需要帮助来解决我的问题,谢谢!

python xml extract integration distinct-values
© www.soinside.com 2019 - 2024. All rights reserved.