splitting an exml file into smaller files
开发者_如何转开发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:
- Parse the XML using a suitable library (BeautifulSoup, lxml etc.)
- Find the element corresponding to each movie. This can be done using a plain
findAll
or may require using an XPATH expression. - 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.
精彩评论