NewUnhandledException
NewUnhandledException

Reputation: 743

Deserialize xml elements along with nodes into a string property

I have the following xml

  <Amendment.Text>
    <Page>4</Page>
    <Line>4</Line>
    <Bold>It is a </Bold>   
    <Italic>Beautiful Day</Italic>
    <Bold>In London</Bold>
    <Italic>17 June 2015</Italic>   
</Amendment.Text>

I want to retrieve the <Bold> and <Italic> elements into a string property

Output (String property content):

<Bold>It is a </Bold>   
    <Italic>Beautiful Day</Italic>
    <Bold>In London</Bold>
    <Italic>17 June 2015</Italic>

My serializable class is as below -

[Serializable]
    public class AmdTextType
    {

        public string Page { get; set; }

        public string Line { get; set; }

        public string Content { get; set; }

    }

I am able to deserialize Page and Line but not able to get the Italic and Bold elements with the tag

Upvotes: 0

Views: 84

Answers (1)

Stu
Stu

Reputation: 2446

Could this not be:

  <Amendment.Text>
    <Page>4</Page>
    <Line>4</Line>
    <Content>CDATA(["
       <Bold>It is a </Bold>   
       <Italic>Beautiful Day</Italic>
       <Bold>In London</Bold>
       <Italic>17 June 2015</Italic>   
    "])
    </Content>
</Amendment.Text>

Upvotes: 2

Related Questions