I have an XML which looks like this.
<nb:myelement param='oxygen'>Value</nb:element>
I am using the following python code.
for sub in dom.getElementsByTagName('nb:myelement'):
if(sub.getAttributeNode("param").nodeValue == 'oxygen'):
value = sub.getElementsByTagName('nb:myelement')[0].toxml()
But the last line is throwing an index out of range execption. How do I get the ‘value’ enclosed by a tag that also has attributes?
There are no other nb:myelement elements in your nb:myelement. So last line is really
If there is only text in nb:myelement, just use text node of this element