def sect(el):
, ,global count_s
, ,global count_t
, ,childList=el.childNodes
, ,for child in childList:
, , , ,if child.nodeName == 'p':
, , , , , ,text = child.childNodes[0].nodeValue
, , , , , ,if text != None:
, , , , , , , ,count_t += len(text)
, , , ,if child.nodeName == 'section':
, , , , , ,count_s += 1
, , , , , ,sect(child)
#---------------------------------------
def parse_fb2(fn):
, ,global count_b , ,
, ,dom = xml.dom.minidom.parse(fn);
, ,dom.normalize()
, ,n_body=dom.getElementsByTagName("body")[0]
, ,sect(n_body)
, ,fb=dom.getElementsByTagName("FictionBook")[0]
, ,childList=fb.childNodes
, ,for child in childList:
# , , print(child.nodeName)
, , , , if child.nodeName == 'binary':
, , , , , ,text = child.childNodes[0].nodeValue
, , , , , ,if text != None:
, , , , , , , ,count_b += len(text)
def MyPrint(adr):