开发者

splitting an exml file into smaller files

开发者 https://www.devze.com 2023-01-16 14:20 出处:网络
开发者_如何转开发the xml file contains information about movies. how do i split the xml file into smaller files? ( so each small file is a separate movie)Without knowing the details, here is a broad o

开发者_如何转开发the xml file contains information about movies. how do i split the xml file into smaller files? ( 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.)
  2. Find the element corresponding to each movie. This can be done using a plain findAll or may require using an XPATH expression.
  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.

0

精彩评论

暂无评论...
验证码 换一张
取 消