如何复杂的XML转换为.NET类? [英] How to convert complex XML to .NET Class?

查看:159
本文介绍了如何复杂的XML转换为.NET类?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这样的 XML ,只是想知道我怎么能转换成 C#类

 < XML版本=1.0编码=UTF-8&GT?;
< TextScrollerItems的xmlns:XSD =htt​​p://www.w3.org/2001/XMLSchema的xmlns:XSI =htt​​p://www.w3.org/2001/XMLSchema-instance>

    <项目类型=文本ID =234>
     <文字颜色=蓝>
       示例文本...
     < /文字>
    < /项目>

    <项目类型=形象ID =2456>
        <图像>
          clientLogo.png
        < /图片>
    < /项目>

    < / TextScrollerItems>
 

解决方案

给一个尝试xsd.exe工具随Visual Studio中。 下面是一些文档: <一href="http://www.$c$cproject.com/Articles/11317/From-XML-to-Strong-Types-in-C">http://www.$c$cproject.com/Articles/11317/From-XML-to-Strong-Types-in-C

I have this XML and just wondering how I can convert into C# class?

<?xml version="1.0" encoding="utf-8"?>
<TextScrollerItems xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

    <Item type="text" ID="234">
     <Text Color="Blue">
       Sample text...
     </Text>
    </Item>

    <Item type="image" ID="2456">
        <Image>
          clientLogo.png
        </Image>
    </Item>

    </TextScrollerItems>

解决方案

give a try to the XSD.exe tool shipped with Visual Studio. Here's some docs: http://www.codeproject.com/Articles/11317/From-XML-to-Strong-Types-in-C

这篇关于如何复杂的XML转换为.NET类?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆