C
cronusf
I have an xml file where I only need to extract data from certain
nodes. I am using XPathNavigator to find the nodes I want. My
question is, once I have the node I want, is there an easy way to
convert it to a C# object. For example, if I have the node:
<Point3>
<x>54.7</x>
<y>55.9</y>
<z>0.005</z>
</Point3>
and a corresponding Point3 structure in C#, is there a way I could do
something like:
Point3 p = (Point3)xpathnavigator.Value();
I tried using ValueAs:
Point3 p = (Point3)xpathnavigator.ValueAs(typeof(Point3));
but it threw an exception. Obviously I could move to the lower level
and use the property ValueAsDouble, but I would like to read in
structs at a time, if possible, rather than hitting every data member.
nodes. I am using XPathNavigator to find the nodes I want. My
question is, once I have the node I want, is there an easy way to
convert it to a C# object. For example, if I have the node:
<Point3>
<x>54.7</x>
<y>55.9</y>
<z>0.005</z>
</Point3>
and a corresponding Point3 structure in C#, is there a way I could do
something like:
Point3 p = (Point3)xpathnavigator.Value();
I tried using ValueAs:
Point3 p = (Point3)xpathnavigator.ValueAs(typeof(Point3));
but it threw an exception. Obviously I could move to the lower level
and use the property ValueAsDouble, but I would like to read in
structs at a time, if possible, rather than hitting every data member.