<text >
<font size="86" spacing="17" />
率誕詭不經唐元奘法師遊西域十有七年撰
</text>
<text >
率誕詭不經唐元奘法師遊西域十有七年撰
</text>
<font size="86" spacing="17" />
率誕詭不經唐元奘法師遊西域十有七年撰
</text>
<text >
率誕詭不經唐元奘法師遊西域十有七年撰
</text>
import xml.etree.ElementTree
tree=xml.etree.ElementTree.ElementTree(file="e:\\Python\\1.xml")
elem=tree.getroot()
file=open("e:\\a.txt",'w')
for a in elem.getiterator("text"):
#print len(a._children)
if len(a._children)>0:
for node in a:
if node.tail<> None:
node.tail.encode('utf-8')
file.write(node.tail.encode('utf-8'))
#print xml.etree.ElementTree.iselement(node)
else:
if a.text<>None:
file.write(a.text.encode('utf-8'))
tree=xml.etree.ElementTree.ElementTree(file="e:\\Python\\1.xml")
elem=tree.getroot()
file=open("e:\\a.txt",'w')
for a in elem.getiterator("text"):
#print len(a._children)
if len(a._children)>0:
for node in a:
if node.tail<> None:
node.tail.encode('utf-8')
file.write(node.tail.encode('utf-8'))
#print xml.etree.ElementTree.iselement(node)
else:
if a.text<>None:
file.write(a.text.encode('utf-8'))