I've created an XML that looks like this.
<?xml version='1.0' encoding='utf-8' standalone='no'?>
<flow xlmns="urn:opendaylight:flow:inventory">
<strict>false</strict>
<instructions>
<instruction>
<apply-action>
<action>
<order>0</order>
<dec-nw-ttl/>
</action>
</apply-action>
</instruction>
</instructions>
I'm sending it to a function that takes two parameters, flow (the XML), and actions (a list of new actions I want to add):
def add_flow_action(flow, actions):
for newaction in actions:
etree.SubElement(action, newaction)
return flow
The function is meant to add more SubElements under the parent named action, so that it looks like this:
<?xml version='1.0' encoding='utf-8' standalone='no'?>
<flow xlmns="urn:opendaylight:flow:inventory">
<strict>false</strict>
<instructions>
<instruction>
<apply-action>
<action>
<order>0</order>
<dec-nw-ttl/>
<new-action-1/> #Comment: NEW ACTION
<new-action-2/> #Comment: NEW ACTION
</action>
</apply-action>
</instruction>
</instructions>
This doesn't work, and it throws the error: TypeError: Argument '_parent' has incorrect type (expected lxml.etree._Element, got list)
Any ideas how to change the function to do this?