I am for option number 2.
Option # 1: If Obj1 is NULL, he will continue to check for null for Obj2, Obj3, Obj4 and Obj5 every time! At least with Option # 2, once it finds that Obj1 is NULL, it does not check the rest of the if statement, which means fewer processing cycles.
Option number 3, of course, is bad. Capturing exceptions is overhead, and if you repeat thousands of nodes, you will feel it - ignore the smell.
My concern is that you may be asking the wrong question. You declare that you use XML, then these objects are really elements, right?
Perhaps if you formulated your question differently and provided more information about the structure of the XML document, we could write a Linq query to pull the value out without all the hard-coded null checks (and the loops that I assume you are also using).
source share