Extracting values from XmlNode/XmlAttribute

  • Thread starter Thread starter MaxMax
  • Start date Start date
M

MaxMax

If I have an XmlNode/XmlAttribute and I want to convert its value to a
"native" c# type (for example boolean), how should I do? I can't (for
example) simply use Boolean.TryParse, because Xml Boolean considers 0 and 1
to be "good" values for a boolean type.

--- bye
 
Hi Max,

As Martin has suggested, you can use the XmlConvert class to convert the
string value(you pick from XmlNode or XmlAttribute ) to the target
type(boolean, integer .....). It is just like the System.Convert class, the
only difference is that XmlConvert class is specific to XML standard awared
convertion.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


This posting is provided "AS IS" with no warranties, and confers no rights.
 
Hi Max,

Have you got any further progress or does the suggestion in previous reply
helps you some? If there is still anything we can help, please feel free to
post here.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


This posting is provided "AS IS" with no warranties, and confers no rights.
 
Hi Max,

Have you got any further progress or does the suggestion in previous reply
helps you some? If there is still anything we can help, please feel free to
post here.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead

This posting is provided "AS IS" with no warranties, and confers no rights.

I think XMLConvert should work for you. Else we can think of using
reflection.
 
Have you got any further progress or does the suggestion in previous reply
helps you some? If there is still anything we can help, please feel free
to
post here.
Yes yes... Simply I wasn't able to find it in the MSDN the first time....
There are so many classes :-)

--- bye
 
Back
Top