Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python write()方法更改我的XML输出_Python_Xml_Parsing_Lxml_Elementtree - Fatal编程技术网

Python write()方法更改我的XML输出

Python write()方法更改我的XML输出,python,xml,parsing,lxml,elementtree,Python,Xml,Parsing,Lxml,Elementtree,当我尝试使用XML.etree.celement库编辑XML文件,然后尝试将更改写入新的XML文件时,我的XML文件会发生更改 我需要对XML文件进行更改,然后仅使用我对文本所做的更改编写一个精确的副本。我曾尝试使用c14n等标准,并使用正确的编码和xml声明,但仍然没有成功 encoding='utf-8',xml_声明=True 该文件仍有一些小更改,例如: 在原始文件中: <remote-name>&#10;glossary_name </remot

当我尝试使用XML.etree.celement库编辑XML文件,然后尝试将更改写入新的XML文件时,我的XML文件会发生更改

我需要对XML文件进行更改,然后仅使用我对文本所做的更改编写一个精确的副本。我曾尝试使用c14n等标准,并使用正确的编码和xml声明,但仍然没有成功

encoding='utf-8',xml_声明=True

该文件仍有一些小更改,例如:

在原始文件中:

<remote-name>&#10;glossary_name        </remote-name>

抱歉,一开始看起来是这样的:&10;新文档中的glossary\u name看起来像:glossary\u name
<remote-name>
glossary_name        </remote-name>
from xml.dom import minidom
import os
import xml.etree.cElementTree as et
import tkFileDialog
from lxml import etree as tt

## Grab the Particular file to convert xml
xmldoc = tt.parse(newfile)
root  = xmldoc.getroot()
##loop through to convert the images to the correct Path
##finds the intro dashboard and converts the image
for dashboard in root.iter('dashboard'):
    if dashboard.get('name') == "Intro":

        ##Loops through the zones within a specified dashboard
        for zone in list(dashboard.iter('zone')):
            if zone.get('id') == ('88'):
                zone.set('param', 'customerFiles/Image/Intro - Top.png')        
    else:
        continue

xmldoc.write_c14n('output.xml')
#os.rename('output.xml',"output.twb")