小编Kri*_*ard的帖子

如何将XML数据解析为自定义C#类的属性?

建立

我的Main()功能中有这个.

List<Token> tokens = new List<Token>();
string path = @"\(some directories)\tokens.xml";
XDocument doc = XDocument.Load(path);
Run Code Online (Sandbox Code Playgroud)

我有这个类有几个属性.

public partial class Token
{
    public Token()
    {
        SetURLs = new List<string>();
        SetNames = new List<string>();
    }

    public string Name { get; set; }
    public List<string> SetURLs { get; set; }
    public List<string> SetNames { get; set; }
    public string Color { get; set; }
    public string PT { get; set; }
    public string Text { get; set; }
}
Run Code Online (Sandbox Code Playgroud)

我有这个XML文件.这是一个片段. …

c# xml linq

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

如果List字符串元素包含来自另一个List的字符串元素,如何删除它?

建立

我有这三个清单.

List<List<string>> tokens = new List<string>();
List<string> token = new List<string>();
List<string> sets = new List<string();
Run Code Online (Sandbox Code Playgroud)

token列表中的一个完整tokens列表.

{"<card>"",
 "    <name>Domri Emblem</name>",
 "    <set picURL="http://magiccards.info/extras/token/Gatecrash/Domri-Rade-Emblem.jpg" picURLHq="" picURLSt="">GTC</set>",
 "    <color></color>",
 "    <manacost></manacost>",
 "    <type>Emblem</type>",
 "    <pt></pt>",
 "    <tablerow>0</tablerow>",
 "    <text></text>",
 "    <token>1</token>",
 "</card>"}
Run Code Online (Sandbox Code Playgroud)

sets名单是这样的.

{"ARB", ..., "AVR", ..., "GTC", ..., "ZEN"}
Run Code Online (Sandbox Code Playgroud)

我想通过每一个tokentokens和删除每个字符串中token包含任何元素set.

tokens列表包含一些token元素.一个token(比如说token1)有一个像这样的元素.

{..., "    <set picURL="http://magiccards.info/extras/token/Gatecrash/Domri-Rade-Emblem.jpg" picURLHq="" picURLSt="">GTC</set>", ...}
Run Code Online (Sandbox Code Playgroud)

另一个 …

c# xml linq

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

标签 统计

c# ×2

linq ×2

xml ×2