Python 将lxml etree拆分为多个etree对象
是否有按索引将子元素的etree对象集拆分为多个etree对象的函数? 例如,如果我的根节点有400个子节点,每个子节点都有子节点,那么我可以从文件的每秒钟中获得4个etree对象吗Python 将lxml etree拆分为多个etree对象,python,lxml,Python,Lxml,是否有按索引将子元素的etree对象集拆分为多个etree对象的函数? 例如,如果我的根节点有400个子节点,每个子节点都有子节点,那么我可以从文件的每秒钟中获得4个etree对象吗 from lxml import etree as ET tree = ET.parse('FileName.xml') root = tree.getroot() firstquarter = root.getchildren() #function to get 0-100 of the child n
from lxml import etree as ET
tree = ET.parse('FileName.xml')
root = tree.getroot()
firstquarter = root.getchildren() #function to get 0-100 of the child nodes
secondquarter = root.getchildren() #function to get 101-200 of the child nodes
thirdquarter = root.getchildren() #function to get 201-300 of the child nodes
fourthquarter = root.getchildren() #function to get 301-400 of the child nodes
你应该可以简单地用类似的东西来做
firstquarter = root.getchildren()[0:100]
等等。谢谢!明天早上我会试一试的。如果成功了,你就可以打勾!不完全是我想要的,但可能是有用的非更少。