简体   繁体   English

将exml文件拆分为较小的文件

[英]splitting an exml file into smaller files

the xml file contains information about movies. xml文件包含有关电影的信息。 how do i split the xml file into smaller files? 如何将xml文件拆分为较小的文件? ( so each small file is a separate movie) (因此,每个小文件都是单独的电影)

Without knowing the details, here is a broad outline of a possible approach: 在不知道细节的情况下,以下是可能的方法的简要概述:

  1. Parse the XML using a suitable library ( BeautifulSoup , lxml etc.) 使用合适的库( BeautifulSouplxml等)解析XML
  2. Find the element corresponding to each movie. 查找与每个电影相对应的元素。 This can be done using a plain findAll or may require using an XPATH expression. 这可以使用普通的findAll来完成,或者可能需要使用XPATH表达式。
  3. Pretty print the subtree starting corresponding to each movie element into separate files. 将与每个电影元素相对应的子树开始漂亮地打印到单独的文件中。

Of course a more detailed answer is not possible unless you post some sample XML and provide more details. 当然,除非您发布一些示例XML并提供更多详细信息,否则不可能提供更详细的答案。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM