While using xml.etree.ElementTree as ET
python package, I would like to get the entire text within an XML tag, which contains some child nodes. Consider the following xml:
<p>This is the start of parent tag...
<ref type="chlid1">child 1</ref>. blah1 blah1 blah1 <ref type="chlid2">child2</ref> blah2 blah2 blah2
</p>
Assuming that the above XML is in node
, then node.text
would just give me This is the start of parent tag...
. However, I want to capture all of the text inside p
tag (along with its child tag's texts) which would result in: This is the start of parent tag... child 1. blah1 blah1 blah1 child2 blah2 blah2 blah2
.
Is there any work-around for this issue? I looked into the documentation but couldn't really find something that works out.