0

I'm not quite sure how to deserialize the following:

<property>
    <price display="yes" plusSAV="no" tax="yes">1000000</price>
    ...
</property>

In my C# model, I have a Property object, which contains a Price property, declared as follows:

    [XmlElement("price")]
    public Price Price { get; set; }

Then in the Price class, I have the following:

   [Serializable]
    public class Price : BaseDisplayAttribute, IDataModel
    {        
        [XmlElement("price")]
        public string PriceValueString { get; set; }

        [XmlAttribute("plusSAV")]
        public string PlusSAVString { get; set; }

        [XmlAttribute("tax")]
        public string TaxString { get; set; }

        ....
    }

All the attributes are deserializing correctly, but the price element is not. Have I declared it correctly here?

Thanks

1 Answer 1

2

Try to use XmlText Attribute like this

[XmlText]
public string PriceValueString { get; set; }
Sign up to request clarification or add additional context in comments.

2 Comments

Yup, that's it. I actually just figured it out and came back to post the answer, but looks like you beat me to it. Thanks Selman :)
glad if I could help :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.