简体   繁体   English

将xml元素以及节点反序列化为字符串属性

[英]Deserialize xml elements along with nodes into a string property

I have the following xml 我有以下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 我想将<Bold><Italic>元素检索到字符串属性中

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 我可以反序列化Page and Line但是不能使用标记获取ItalicBold元素。

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>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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