1
私はこのようになります私のxmlファイルにテキストタグ(PDFはpopplers-utilsのからpdftohtmlを使用してXMLに変換)があります。xml.domのminidomを使用して内部コンテンツを文字列として取得する方法は?
<text top="525" left="170" width="603" height="16" font="1">..part of old large book</text>
<text top="546" left="128" width="645" height="16" font="1">with many many pages and some <i>italics text among 'plain' text</i> and more and more text</text>
<text top="566" left="128" width="642" height="16" font="1">etc...</text>
を、私はテキストは、このサンプルコードでテキストタグでenvolved取得することができます。
import string
from xml.dom import minidom
xmldoc = minidom.parse('../test/text.xml')
itemlist = xmldoc.getElementsByTagName('text')
some_tag = itemlist[node_index]
output_text = some_tag.firstChild.nodeValue
# if there is all text inside <i> I can get it by
output_text = some_tag.firstChild.firstChild.nodeValue
# but no if <i></i> wrap only one word of the string
しかし内容別のタグ内(<i> or <b>...)
とオブジェクトを取得することはできませんいずれかのjavascriptのinnerHTMLメソッドまたは再ようなプレーンな文字列としてすべてのテキストを取得するための最良の方法は何
場合、私は「のnodeValue」を取得することはできませんnodeValue全体ではなくいくつかの単語をラップしても、子タグに呪いをかける?
おかげ