这可能是一个基本问题,但我有一个 xml 格式的剧本。我想抓住演讲者和演讲者在字典中的行,以便将其添加到数组中。这是格式
<SPEECH>
<SPEAKER>Narrator</SPEAKER>
<LINE>Two households, both alike in dignity,</LINE>
<LINE>In fair Verona, where we lay our scene,</LINE>
<LINE>From ancient grudge break to new mutiny,</LINE>
<LINE>Where civil blood makes civil hands unclean.</LINE>
<LINE>From forth the fatal loins of these two foes</LINE>
<LINE>A pair of star-cross'd lovers take their life;</LINE>
<LINE>Whole misadventured piteous overthrows</LINE>
<LINE>Do with their death bury their parents' strife.</LINE>
<LINE>The fearful passage of their death-mark'd love,</LINE>
<LINE>And the continuance of their parents' rage,</LINE>
<LINE>Which, but their children's end, nought could remove,</LINE>
<LINE>Is now the two hours' traffic of our stage;</LINE>
<LINE>The which if you with patient ears attend,</LINE>
<LINE>What here shall miss, our toil shall strive to mend.</LINE>
</SPEECH>
所以我想抓住Narrator
演讲者和他/她拥有的台词并将其添加到字典中。之后,我想将字典添加到数组中,然后清除字典。
我怎样才能做到这一点?
谢谢