Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6853669
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T01:32:22+00:00 2026-05-27T01:32:22+00:00

I have xml document (you may look it up here ) from web request.

  • 0

I have xml document (you may look it up here) from web request.

I need to get values of ccy, base_ccy, buy and sale attributes from each “exchangerate” element:

<exchangerate ccy="EUR" base_ccy="UAH" buy="10.81284" sale="10.81284"/>

I’ve manually created class ExchangeRate, which is looks like this:

[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; }
}

and trying to deserialize xml-element “exchangerate” (which I’ve isolate from whole xml-document) to the instance of ExchangeRate class in this way:

private ExchangeRate DesereilizeXMLNode(XmlNode node)
{
    XmlSerializer mySerializer = new XmlSerializer(typeof(ExchangeRate));
    TextReader reader = new StringReader(node.OuterXml);

    return (ExchangeRate)mySerializer.Deserialize(reader);
}

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.

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T01:32:23+00:00Added an answer on May 27, 2026 at 1:32 am

    You have to specify a Serializable for the whole syntax of the XML file for the Deserialize to work! So from the root node in the XML down to this node. (I can’t give you an example as your lookup url is not working for me; 501)


    EDIT:

    Well then you will have to find the elements and their attributes manually, like the example below. You can’t individually Deserialize XmlElements, unless you convert them to an XmlDocument, but that’s a bit overdone.

    XmlDocument doc = new XmlDocument();
    doc.Load("file.xml");
    
    XmlNodeList nodes = doc.SelectNodes("/account_order/row/exchangerate");
    foreach (XmlNode node in nodes)
    {
        XmlAttribute ccyAttribute = node.Attributes["ccy"];
        //etc...
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following XML document: <projects> <project> <name>Shockwave</name> <language>Ruby</language> <owner>Brian May</owner> <state>New</state> <startDate>31/10/2008
I have an xml document object that I need to convert into a string.
I have document source in XML. I need to generate PDF and HTML pages
Hi I want to read an XML document but it may have some of
I have an XML document with un-namespaced elements, and I want to use XSLT
I have an XML document: var xml:XML = new XML(<rootNode> <head> <meta name=template content=Default
I have an XML document something like ::: <?xml version=1.0 encoding=utf-8?> <?mso-application progid=Excel.Sheet?> <Workbook
I have an XML document that I'm trying to style via CSS. A relevant
I have an XML document looking similar to this: <items> <item cat=1 owner=14>bla</item> <item
I have an xml document where an xml node with a particular name, say

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.