Link to home
Start Free TrialLog in
Avatar of dkim18
dkim18

asked on

Check for xmlnodelist != null not enouhg?

Do I also need to check for how XmlNodeList it brought back form my selectNodes() method?

I only checked the not node but my xml file has no record of <titles><yyyy>  on this iteration. why would secondaryTitles != null fail?
My code enters that if statement.
Do I need to check for .count = 0 property too?

 foreach (XmlNode element in elements)
{
 

XmlNodeList secondaryTitles = element.SelectNodes("titles/yyyy"); <===
                  if (secondaryTitles != null)                     <=== count is 0 and the code enters here
                {
                    foreach (XmlNode node in secondaryTitles)
                    {
                                doing somehting here
                     }
                 }
}
Avatar of dkim18
dkim18

ASKER

After each loop, do I need to set those xmlNodeList to null?
Avatar of dkim18

ASKER

When I debug it and check the line I am no on yet, the count property of the xmlnodelist has value already.
ASKER CERTIFIED SOLUTION
Avatar of AndyAinscow
AndyAinscow
Flag of Switzerland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial