none
Want to Convert my XML into a Key Value Pair or as a Dictionary. RRS feed

  • Question

  • Hi,

    Below is my XML structure.

    <MyData>

    <Data>

    <Name>Test1</Name>

    <Value>Pass</Value>

    <ID>1</ID>

    </Data>

    <Data>

    <Name>Test2</Name>

    <Value>Fail</Value>

    <ID>2</ID>

    </Data>

    <Data>

    <Name>Test3</Name>

    <Value>DependentFailed</Value>

    <ID>3</ID>

    </Data>

    </MyData>

    I want to convert this into a dictionary while converting using XML Serializer.

    Want only Name and Value fields as Key (Name) and Value(Value).

    Class structure will be

    Class MyData

    {

    [XmlElement]

    public Dictionary<string,string> Data {get;set;}

    }

    What attributes i have to specify in XmlElement Tag to achieve this!!?

    Tuesday, February 12, 2019 8:50 AM