Similar to Narrative.readNode(), but looks
for the content in an optional child of the given node. See Section 18.7, “Narrative.readNode(): Read XML (static
method)”.
# - - - N a r r a t i v e . r e a d C h i l d
@staticmethod
def readChild(node, childName):
"""Look for a child with narrative content.
"""
#-- 1 --
# [ childList := list of all children named childName ]
childList = node.xpath(childName)
#-- 2 --
# [ if childList is nonempty ->
# return a Narrative instance representing the
# narrative content of childList[0]
# else -> return None ]
if len(childList) > 0:
return Narrative.readNode(childList[0])
else:
return None