brandonb21
New Member
I have the following XML structure\[code\]<root> <OuterLevel> <Node> <Name>NodeA</Name> </Node> <Node> <Name>NodeB</Name> <Node> <SpecialNode> <Name>NodeZ</Name> </SpecialNode> </OuterLevel> </root>\[/code\]I did some reading on python's ElementTree XML API and I wanted to compare an element's tag with a string. According to the document found on http://docs.python.org/library/xml.etree.elementtree.html, the tag of an element is a string. I wrote the following python code to test for equality:\[code\]import xml.etree.ElementTree as ETtree = ET.parse('sampleFile.xml')root = tree.getroot()if root[0][0].tag != 'Node'print("not equal")\[/code\]However, when I ran the python code. I keep getting SyntaxError: invalid syntax with a carrot sign pointing at the ' after Node. I can print the results of root[0][0].tag Is it not possible to compare that with a string?