tags:

views:

71

answers:

1

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?

A: 

If all you need to do is validate that the XML document adheres to given rules or format you might want to use XML Schema for that rather than LINQ.

Cornelius
They don't exist in the SDK. No Schemas, no xpath... Really not much of anything.
cw