How to validate XML data

I have a scenario where I get an XML, I am using queryXMLNode and mapping the xml element value to IS document. When I get a null value in one node, I want to get the value from other node which will be always has value. Please advise how to do this.

Here you can use step like pub.xml:getXMLNodeIterator and pass the node name in criteria field.If the result is true then you can convert node to document else you can again make query with other node.