0
我編輯XML文件,該文件是原來那樣的xml文件:問題解析
<SequencerLoopCommand id="1073"
IterationCount="2"
CommandList="1241 1242"
Name="Loop Stream IDU64ToIDU63">
<IterateLoadSizeCommand id="1241"
LoadType="STEP"
LoadUnits="KILOBITS_PER_SECOND"
LoadStart="100"
LoadEnd="200"
LoadStep="100"
CustomLoadList=""
StreamBlockList="1543"
Name="Iterate Stream IDU64ToIDU63">
</IterateLoadSizeCommand>
<WaitCommand id="1242"
WaitTime="5"
Name="Stream IDU64ToIDU63">
</WaitCommand>
</SequencerLoopCommand>
用下面的代碼...
doc = minidom.parse("directory")
#processing
fh = open(os.path.join(self.__dirname,self.__xmlfile),"w")
doc.writexml(fh)
fh.close()
doc.unlink()
在那之後,我的新的XML是一樣的東西:
<SequencerLoopCommand CommandList="1241 1242" IterationCount="2" Name="Loop Stream IDU64ToIDU63" id="1073">
<IterateLoadSizeCommand CustomLoadList="" LoadEnd="200" LoadStart="100" LoadStep="100" LoadType="STEP" LoadUnits="KILOBITS_PER_SECOND" Name="Iterate Stream IDU64ToIDU63" StreamBlockList="1543" id="1241">
</IterateLoadSizeCommand>
<WaitCommand Name="Stream IDU64ToIDU63" WaitTime="5" id="1242">
</WaitCommand>
</SequencerLoopCommand>
我需要新文件具有與舊文件相同的結構。任何提示?
謝謝
我知道'xml.dom.minidom'的方式,除非你明確地改變它,否則它只能留下空白。你在代碼的#處理中做了些什麼?你在路上的某處正常嗎? – 2010-06-01 09:04:23