intertext() takes exactly 1 positional arguement (2 given)

ever13

New Member
Not exactly sure how to deal with this error...Code:\[code\]import xml.etree.ElementTree as ETtree = ET.parse('network_objects.xml')root = tree.getroot()for network in root.iterfind('network_object'): name = network.find('Name') class_name = network.find('Class_Name') color = network.find('color') for netmaskElement in network.iterfind('netmask'): netmask = network.itertext('netmask') for ipaddyElement in network.iterfind('ipaddr'): ipaddy = network.find('ipaddr') print (name.text,class_name.text,ipaddy.text,netmask,color.text)\[/code\]Error:\[code\]builtins.TypeError: itertext() takes exactly 1 positional argument (2 given)line 10, in <module>netmask = network.itertext('netmask')\[/code\]The XML itself, as an example:\[code\]<network_objects><network_object><Name>Internal-192.168.112.0_24b</Name><Class_Name>network</Class_Name><add_adtr_rule>false</add_adtr_rule><broadcast><![CDATA[allow]]></broadcast><color><![CDATA[dark orchid]]></color><comments><![CDATA[no comment]]></comments><edges/><ipaddr><![CDATA[192.168.112.0]]></ipaddr><location><![CDATA[internal]]></location><location_desc><![CDATA[]]></location_desc><netmask><![CDATA[255.255.255.0]]></netmask><type><![CDATA[network]]></type></network_object></network_objects>\[/code\]There are course other objects that do not contain netmask, which I assume is where the error is coming from, however I assumed the for loop would correct for that.How do I fix this? :)
 
Back
Top