这里
<root>
<SchoolOrInstitution schoolType="highschool">
<SchoolName>BUTLER HIGH SCHOOL</SchoolName>
<Degree degreeType="highschool"/>
</SchoolOrInstitution>
<SchoolOrInstitution schoolType="highschool">
<SchoolName>BUTLER HIGH SCHOOL</SchoolName>
<Degree degreeType="highschool"/>
</SchoolOrInstitution>
<SchoolOrInstitution schoolType="highschool">
<SchoolName>BUTLER HIGH SCHOOL</SchoolName>
<Degree degreeType="highschool"/>
</SchoolOrInstitution>
..............
</root>
Run Code Online (Sandbox Code Playgroud)
我想根据SchoolOrInstitution标签的数量将此xml拆分为多个文件.
每个XML应该有3个这样的标记.
因此,如果邮件文件有9个SchoolOrInstitution标签,则应创建3个子文件.
和root标签也将分配给所有的3个文件.
xml_split是一个XML :: Twig附带的工具,看起来非常接近你想要的.xml_split -g3 -l1 my.xml会让你大部分时间,唯一的区别是顶级元素将具有由工具分配的标签名称而不是原始名称.