简体   繁体   中英

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

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>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM