Deserialized xml - check if has child nodes without knowing specific type

Posted by AndyC on Stack Overflow See other posts from Stack Overflow or by AndyC
Published on 2010-03-23T12:11:34Z Indexed on 2010/03/23 12:13 UTC
Read the original article Hit count: 287

Filed under:
|
|

I have deserialized an xml file into a C# object and have an "object" containing a specific node I have selected from this file.

I need to check if this node has child nodes. I do not know the specific type of the object at any given time.

At the moment I am just re-serializing the object into a string, and loading it into an XmlDocument before checking the HasChildNodes property, however when I have thousands of nodes to check this is extremely resource intensive and slow.

Can anyone think of a better way I can check if the object I have contains child nodes?

Many thanks :)

© Stack Overflow or respective owner

Related posts about c#

Related posts about Xml