小编use*_*960的帖子

如何将XML反序列化为json和json到c#类?

   // This is my xml data I am trying to map this to my .net classes. By converting XML to json and json back to C# classes.

       string xml = @"  <ReportTemplate>
      <Page Id='1' LayoutId='1'>
        <Section Id='1'>
          <Body>TEststindfgdfgf</Body>
        </Section>`enter code here`
        <Section Id='2'>
          <Content Id='9834ebcd0e9537c315a42cf0d8ed32745f89827c' Type='News'></Content>
        <Content Id='9834ebcd0e9537c315a42cf0d8ed32745f89827c' Type='News' ></Content>
        </Section>
        <Section Id='3'>
           <Content Id='9834ebcd0e9537c315a42cf0d8ed32745f89827c' Type='News'></Content>
        </Section>
      </Page>
      <Page Id='2' LayoutId='1'>
        <Section Id='1'>
           <Content Id='9834ebcd0e9537c315a42cf0d8ed32745f89827c' Type='News'></Content>
          <Content Id='9834ebcd0e9537c315a42cf0d8ed32745f89827c' Type='News'></Content>
        </Section>
        <Section Id='2'>
           <Content Id='9834ebcd0e9537c315a42cf0d8ed32745f89827c' Type='News'></Content>
        </Section>
        <Section Id='3'>
          <Body>dfgdgggf;</Body>
        </Section> …
Run Code Online (Sandbox Code Playgroud)

c# xml serialization json

1
推荐指数
1
解决办法
4550
查看次数

标签 统计

c# ×1

json ×1

serialization ×1

xml ×1