私のxmlファイルはこのようなものです
<S_Row>
<S_Cell><S_CellBody></S_CellBody></S_Cell>
<S_Cell><S_CellBody></S_CellBody></S_Cell>
<S_Cell><S_CellBody></S_CellBody></S_Cell>
</S_Row>
私は次のようにPythonで処理しています:
for i, S_Cell in enumerate(S_Row.findall('S_Cell')):
for S_CellBody in S_Cell.getchildren():
if i==0:
S_CellBody.text="ABC"
これにより、xml ファイルに次のような出力が得られます。
<S_Row>
<S_Cell><S_CellBody>ABC</S_CellBody></S_Cell>
<S_Cell><S_CellBody></S_CellBody></S_Cell>
<S_Cell><S_CellBody></S_CellBody></S_Cell>
</S_Row>
別の行を追加して、次のように 2 行目 (1 列目) に要素を追加する場合:
<S_Row>
<S_Cell><S_CellBody>ABC</S_CellBody></S_Cell>
<S_Cell><S_CellBody></S_CellBody></S_Cell>
<S_Cell><S_CellBody></S_CellBody></S_Cell>
</S_Row>
<S_Row>
<S_Cell><S_CellBody>DEF</S_CellBody></S_Cell>
<S_Cell><S_CellBody></S_CellBody></S_Cell>
<S_Cell><S_CellBody></S_CellBody></S_Cell>
</S_Row>
私は何をすべきか?