0

私の目標は、テキストを取得することです: 27. The method according to claim 23 wherein...
を含むタグ内のテキストを取得するにはどうすればよいですか<?。グーグルで調べたところ、phpショートタグと呼ばれていると思います。

lxml、xpaths を使用していますが、タグまたはノードとして登録されていないようです。itertext() を試しましたが、うまくいきません。

 <claim id="CLM-00027" num="00027">
            <claim-text>                <?insert-start id="REI-00005" date="20191203" ?>27. The method according to claim 23 wherein the amorphous metal is selected from the group consisting of Zr based alloys, Ti based alloys, Al based alloys, Fe based alloys, La based alloys, Cu based alloys, Mg based alloys, Pt based alloys, and Pd based alloys.                <?insert-end id="REI-00005" ?></claim-text>
        </claim>
4

2 に答える 2

1

インデックスによって特定の子ノードにアクセスします。

from xml.etree import ElementTree as ET
tree = ET.parse('path_to_your.xml')

root = tree.getroot()

print(root[0].text)

出力:

        27. The method according to claim 23 wherein the amorphous metal is selected from the group consisting of Zr based alloys, Ti based alloys, Al based alloys, Fe based alloys, La based alloys, Cu based alloys, Mg based alloys, Pt based alloys, and Pd based alloys.                
于 2020-07-01T06:21:02.050 に答える