gpt4 book ai didi

c# - .NET XML 反序列化

转载 作者:太空宇宙 更新时间:2023-11-03 14:12:48 25 4
gpt4 key购买 nike

我有以下 XML 提要。我需要对对象的 List 进行反序列化。我如何在 .NET 4.0 C# 中实现这一目标?

<body>
<games>
<sports>
<lot_name>Football</lot_name>
<prizes>
<!-- For each prize the "division_" tag ends with different number -->
<divisions_1>
<divisions>1</divisions>
<match>5-2</match>
<pay>$10</pay>
</divisions_1>
<divisions_2>
<divisions>2</divisions>
<match>3-2</match>
<pay>$5</pay>
</divisions_2>
</prizes>
</sports>
</games>
</body>

最佳答案

here , 很好的解释。

xsd.exe is a handy little tool that comes with the .NET SDK (Software Development Kit) that can make life easy when you want to quickly go from an XML input to a strongly-typed .NET object.

If you're starting with an XML file:

1) Open the XML file in Visual Studio

2) From the XML menu click "Create Schema". This will generate a XSD file.

其余here .

关于c# - .NET XML 反序列化,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7283884/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com