XElement Path Validation
- by cw
Hello,
I am trying to validate Elements and Attributes exist in an XElement. Basically, I was wondering if anyone had a generic way to check if a give path is null. I don't have access to System.Xml.XPath (doing this for compact framework).
Basically what I have is:
<root value"1000">
<element1>test<element1>
<element2>1<element2>
....
<element30>
<subElement1>stuff</subElement1>
</element30>
</root>
Now I know you can "if this is null do this and that". But since there is upwards of 30 elements that can be under root, which are optional elements, I need a way to grab the value if it exists and convert it to the correct type (which I know) in a nice compact way.
Any suggestions?