Note that there are some explanatory texts on larger screens.

plurals
  1. POParsing xml element to class
    primarykey
    data
    text
    <p>I have xml document (you may look it up <a href="https://www.evernote.com/shard/s6/sh/d3ac80b9-6177-4943-9563-3cd0e120bddd/85b396cb8b9696a97bbbf9bf02ff059f" rel="nofollow">here</a>) from web request.</p> <p>I need to get values of ccy, base_ccy, buy and sale attributes from each "exchangerate" element:</p> <pre><code>&lt;exchangerate ccy="EUR" base_ccy="UAH" buy="10.81284" sale="10.81284"/&gt; </code></pre> <p>I've manually created class ExchangeRate, which is looks like this:</p> <pre><code>[Serializable] public class ExchangeRate { [XmlAttribute("ccy")] public string Ccy { get; set; } [XmlAttribute("base_ccy")] public string Base_ccy { get; set; } [XmlAttribute("buy")] public string Buy { get; set; } [XmlAttribute("sale")] public string Sale { get; set; } } </code></pre> <p>and trying to deserialize xml-element "exchangerate" (which I've isolate from whole xml-document) to the instance of ExchangeRate class in this way:</p> <pre><code>private ExchangeRate DesereilizeXMLNode(XmlNode node) { XmlSerializer mySerializer = new XmlSerializer(typeof(ExchangeRate)); TextReader reader = new StringReader(node.OuterXml); return (ExchangeRate)mySerializer.Deserialize(reader); } </code></pre> <p>When I debuging DesereilizeXMLNode method I receiving exception while calling deserialization method. The exception is XAMLParseException in MainWindow.xaml in first line of the Grid element (which is weird) and I think it is not a proper place for calling exception.</p> <p>The question is: where was I wrong? Am I wrong when tried to create an object instance from xml-element in this way? Maybe I've made mistake when tried to deserialize only xml-element with attributes without deserialization of whole xml-document?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload