I don't think Beautiful soup is up to cracking oo3's xml format; it doesn't respect nesting.
This commit is contained in:
parent
22971e87d3
commit
170c76ca08
1 changed files with 23 additions and 0 deletions
|
@ -1,2 +1,25 @@
|
||||||
#!/usr/bin/python
|
#!/usr/bin/python
|
||||||
|
import gzip
|
||||||
|
from BeautifulSoup import BeautifulStoneSoup
|
||||||
|
import sys
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def __main(oo_file):
|
||||||
|
g = open(oo_file)
|
||||||
|
o = open('output.xml', 'w')
|
||||||
|
try:
|
||||||
|
soup = BeautifulStoneSoup(g)
|
||||||
|
count = 0
|
||||||
|
for item in soup.outline.root:
|
||||||
|
if item.parent != soup.outline.root:
|
||||||
|
continue
|
||||||
|
count = count + 1
|
||||||
|
print count
|
||||||
|
finally:
|
||||||
|
g.close()
|
||||||
|
o.close()
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
__main(sys.argv[1])
|
||||||
|
|
Loading…
Reference in a new issue