I have the following condition,
if (myXElement.FirstNode.NodeType == XmlNodeType.CDATA)
This throws an exception if there is no FirstNode
in myXElement
, so I have to check first if there is any.
Note that I need to check for nodes not elements.