小编Lju*_*nov的帖子

从XML文档获取指定的节点值

我在浏览XML文档(使用C#)时遇到问题,并获得所有必要的值.我成功浏览了XML文档中所有指定的XmlNodeLists,成功获取了所有XmlNode值,但我必须在此XmlNodeList之外获取一些值.

例如:

<?xml version="1.0" encoding="UTF-8" ?>
<Element xsi:schemaLocation="http://localhost/AML/CaseInvestigationMangement/Moduli/XmlImportControls/xsdBorrow.xsd xsd2009027_kor21.xsd" Kod="370" xmlns="http://localhost/AML/CaseInvestigationMangement/Moduli/XmlImportControls/xsdBorrow.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
/2001/XMLSchema-instance">
    <ANode>
        <BNode>
            <CNode>
                <Example>
                    <Name>John</Name>
                    <NO>001</NO>
                </Example>
            </CNode>
        </BNode>
        <ID>1234</ID>
        <Date>2011-10-01</Date>
    </ANode>
    <ANode>
        <BNode>
            <CNode>
                <Example>
                    <Name>Mike</Name>
                    <NO>002</NO>
                </Example>
            </CNode>
        </BNode>
        <ID>5678</ID>
        <Date>2011-03-31</Date>
    </ANode>
</Element>
Run Code Online (Sandbox Code Playgroud)

这是获取XML文档中每个找到的ANode中节点Name和NO的值的代码:

XmlDocument xml = new XmlDocument();
xml.LoadXml(myXmlString); //myXmlString is the xml file in string //copying xml to string: string myXmlString = xmldoc.OuterXml.ToString();
XmlNodeList xnList = xml.SelectNodes("/Element[@*]/ANode/BNode/CNode");
foreach (XmlNode xn in xnList)
{
  XmlNode example = xn.SelectSingleNode("Example");
    if (example != null)
    {
        string …
Run Code Online (Sandbox Code Playgroud)

c# xml xmldocument

25
推荐指数
1
解决办法
19万
查看次数

C#将List <string>添加到List <List <string >>数组

我能添加List<string>List<List<string>>数组中这样说:

        List<string> first = new List<string> { "one", "two", "three" };
        List<string> second = new List<string> { "four", "five", "six" };

        List<List<string>> list_array = new List<List<string>> { first, second };
Run Code Online (Sandbox Code Playgroud)

现在我需要创建几个填充了数据库记录的列表,然后将这个列表添加到List<List<string>>数组中:

    List<List<string>> array_list;

            while (dr.Read())
            {
                string one = dr["Row1"].ToString();
                string two = dr["Row2"].ToString();

                List<string> temp_list = new List<string> { one, two };

                //Here I need to add temp_list to array_list
            }
Run Code Online (Sandbox Code Playgroud)

c# arrays list

9
推荐指数
1
解决办法
3万
查看次数

SQL删除编号最小的重复行

我找不到合适的方法来删除数字最小的sql表中的重复键.如果存在具有相同Number的重复行,则需要删除其中一个.

例如

Key     Number  Description

11111   5   Desc1
11111   4   Desc2
22222   2   Desc1
22222   2   Desc2
33333   3   Desc1
33333   5   Desc2
Run Code Online (Sandbox Code Playgroud)

在这里,我需要删除第4行,其中第4行小于第5行,第3行或第4行之一,第5行第3行,第3行,第3行,第3行,第5行.

sql sql-server duplicate-removal

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

标签 统计

c# ×2

arrays ×1

duplicate-removal ×1

list ×1

sql ×1

sql-server ×1

xml ×1

xmldocument ×1