用vs2012的命令利用xsd文件生成对应的C#类,把xml的string类型映射到生成的类

输入命令:

xsd d:\TDDOWNLOAD\atom-author-link.xsd /c /language:C# /outputdir:d:\

含义:

将d:\TDDOWNLOAD\atom-author-link.xsd 架构 生成类 语言为C# 输出目录是d:\

 

把xml映射到生成的C#类:

        [XmlSerializerFormat]
        public LocHubOrder XMLMapOrder(string xml)
        {
            byte[] array = Encoding.ASCII.GetBytes(xml);
            LocHubOrder LHOrder;
            using (MemoryStream stream = new MemoryStream(array))
            {
                XmlSerializer serializer = new XmlSerializer(typeof(LocHubOrder));
                stream.Seek(0, SeekOrigin.Begin);
                LHOrder = serializer.Deserialize(stream) as LocHubOrder;
            }
           return LHOrder;
        }

 

posted @ 2014-12-01 16:06  小姐,请叫我“序员”好吗  阅读(1805)  评论(0编辑  收藏  举报