내가 선생님이야 댓글. 나는 내가 배정한 에세이에 대해 논평 한 모든 학생들의 목록과 그들이 말한 것을 원한다. Drive API는 너무 힘들었지 만 zip으로 다운로드하여 XML을 파싱 할 수 있다고 생각했습니다.추출 DOCX는
주석은 주석 텍스트 w:t
와 함께, w:comment
태그에 태그가 지정됩니다. 그것은 쉬워야하지만 XML (etree)이 나를 죽이고 있습니다. 튜토리얼을 통해
z = zipfile.ZipFile('test.docx')
x = z.read('word/comments.xml')
tree = etree.XML(x)
는 그럼 난 이렇게 :
children = tree.getiterator()
for c in children:
print(c.attrib)
이 결과 :
{}
{'{http://schemas.openxmlformats.org/wordprocessingml/2006/main}author': 'Joe Shmoe', '{http://schemas.openxmlformats.org/wordprocessingml/2006/main}id': '1', '{http://schemas.openxmlformats.org/wordprocessingml/2006/main}date': '2017-11-17T16:58:27Z'}
{'{http://schemas.openxmlformats.org/wordprocessingml/2006/main}rsidR': '00000000', '{http://schemas.openxmlformats.org/wordprocessingml/2006/main}rsidDel': '00000000', '{http://schemas.openxmlformats.org/wordprocessingml/2006/main}rsidP': '00000000', '{http://schemas.openxmlformats.org/wordprocessingml/2006/main}rsidRDefault': '00000000', '{http://schemas.openxmlformats.org/wordprocessingml/2006/main}rsidRPr': '00000000'}
{}
{'{http://schemas.openxmlformats.org/wordprocessingml/2006/main}val': '0'}
{'{http://schemas.openxmlformats.org/wordprocessingml/2006/main}val': '0'}
{'{http://schemas.openxmlformats.org/wordprocessingml/2006/main}val': '0'}
그리고이 후
나는 완전히 오전 붙어있어. 나는element.get()
과
element.findall()
을 사용해 보았습니다. 값 (
'{http://schemas.openxmlformats.org/wordprocessingml/2006/main}val'
)을 복사/붙여 넣기해도이 반환됩니다.
아무도 도와 줄 수 있습니까?
요소의 텍스트 내용은 '텍스트'속성이다. 'print (c.text)'는 흥미로운 것을 생성합니까? – mzjn
'A = tree.get ("{} http://schemas.openxmlformats.org/wordprocessingml/2006/main 브로') 인쇄 (a.text)' 결과에 대해 'C'를 AttributeError' 어린이 : 인쇄 (c.text) 코멘트에' 결과! 내가 다른 분야에 어떻게 접근 할 수 있는지 알고 있니? –