Python and BeautifulSoup shuffles my tags around?

bubykung

New Member
This has been puzzling me for a while now, and I can not figure out what's going on here. This is the original XML file:\[code\]<?xml version="1.0" encoding="UTF-8" ?><book> <meta> <title>Some Title</title> <creator>Another Author</creator> <language>en-US</language> ... </meta> <chapter> ... </chapter></book>\[/code\]Then I read the file in:\[code\]with open(filename) as f : soup = BeautifulSoup(f); print(soup.root)\[/code\]and that, oddly, dumps the following:\[code\]<html><body><book><meta/><title>Some Title</title><creator>Some Author</creator><language>en-US</language>...\[/code\]So why oh why is the \[code\]<meta>\[/code\] tag in the soup empty, when it is not in the original XML file? (I could swear that this worked just two weeks ago, and I could also swear that I've not touched the script. I did make some slight changes to the XML file further down, but I fail to see a correlation.)
 
Back
Top