Is there any way to do this without using a Try… Catch?
[code]Dim xml as New XmlDocument
Dim root as XMLNode
Dim n as XMLNode
root = xml.AppendChild(xml.CreateElement(“Product”))
Try
n = xml.ImportNode( CreateAChildNode(), True ) // NilObjectException here if no child node comes back
root.AppendChild( n )
catch err as NilObjectException
// No child
End Try[/code]
[code]Private Function CreateAChildNode() As XMLNode
Dim xml as New XmlDocument
Dim nChild, n as XMLNode
if SomeBoolean then
nChild = xml.AppendChild(xml.CreateElement("Details"))
n = nChild.AppendChild(xml.CreateElement("StockNumber"))
n.AppendChild(xml.CreateTextNode( str( theStockNumber )))
end if
Return nChild
End Function[/code]
Thank you