A
Alex
Hi,
Can someone explain why I get System.NullReferenceException and how
does this exception fit into the logic of XmlDocument class in .Net
framework.
I am reading an xml document, such as one shown below, using the
XmlDocument class. For some reason when I get to the
/schedule/tasks/task/comments node and try to read it using
node.FirstChild.Value I get System.NullReferenceException. I tried
using IsNothing() to check for null values, but it doesn't seem to
work. Does this behavior seem logical to you? Why should I be forced
to catch this exception if I only want to process an empty xml node?
In the example below, empty <comments> tag means there's no comments.
<schedule>
<name>Customer 1</name>
<start_date>2003-04-04</start_date>
<tasks>
<task>
<caption>Task 1</caption>
<duration>2</duration>
<comments></comments>
</task>
</tasks>
</schedule>
Thanks!
Alex
Can someone explain why I get System.NullReferenceException and how
does this exception fit into the logic of XmlDocument class in .Net
framework.
I am reading an xml document, such as one shown below, using the
XmlDocument class. For some reason when I get to the
/schedule/tasks/task/comments node and try to read it using
node.FirstChild.Value I get System.NullReferenceException. I tried
using IsNothing() to check for null values, but it doesn't seem to
work. Does this behavior seem logical to you? Why should I be forced
to catch this exception if I only want to process an empty xml node?
In the example below, empty <comments> tag means there's no comments.
<schedule>
<name>Customer 1</name>
<start_date>2003-04-04</start_date>
<tasks>
<task>
<caption>Task 1</caption>
<duration>2</duration>
<comments></comments>
</task>
</tasks>
</schedule>
Thanks!
Alex