XML 数据不跟在 ID 后面,输入的条目比应该的多。

XML Data not following ID, making more entries then it should.

我正在尝试从这个 XML 中获取 'max' 买卖元素以遵循 tyeID;

这是我使用的代码; XML 是 link(见下文)

       private void JitaOrePrices()
    {
        ListViewItem itm;

        //listview settings.
        listView1_Jita.View = View.Details;
        listView1_Jita.GridLines = true;
        listView1_Jita.FullRowSelect = true;

        //convert to string.
        string string1 = "http://api.eve-central.com/api/marketstat?typeid=34&
        minQ=1&typeid=35&minQ=1&typeid=36&minQ=1&typeid=37&minQ=1&typeid=38&
        minQ=1&typeid=39&minQ=1&typeid=40&minQ=1&typeid=11399&minQ=1&
        typeid=27029&minQ=1&usesystem=30000142";

        // add colums to put into. 
        listView1_Jita.Columns.Add("Type", 35);
        listView1_Jita.Columns.Add("(B)", 43);
        listView1_Jita.Columns.Add("(S)", 43);

        //set arrays to put into.
        string[] arr = new string[3];

        XElement xdoco = XElement.Load(string1);
        XmlDocument doco = new XmlDocument();
        doco.Load(string1);            
        XmlNodeList Blist = doco.SelectNodes("/evec_api/marketstat/type");
        XmlNodeList Clist = doco.SelectNodes("/evec_api/marketstat/type/buy");
        XmlNodeList Dlist = doco.SelectNodes("/evec_api/marketstat/type/sell");
        foreach (XmlNode xnod in Blist)           
            foreach (XmlElement znod in Clist)
                foreach (XmlElement dnod in Dlist)
        {
            if (xnod.Attributes["id"] != null)
                arr[0] = xnod.Attributes["id"].InnerText;
                arr[1] = znod.SelectSingleNode("max").InnerText;
                arr[2] = dnod.SelectSingleNode("max").InnerText;

                itm = new ListViewItem(arr);
            itm.Font = new Font("Tahima", 9);
            listView1_Jita.Items.Add(itm);        
        }


    }

发生了什么事? - 它采用最大买卖价值并制作一个比预期更大的清单,我希望它 return 每个 ID 号只有 2 个值。

XML 看起来像这样;

http://api.eve-central.com/api/marketstat?typeid=34&minQ=1&typeid=35&minQ=1&typeid=36&minQ=1&typeid=37&minQ=1&typeid=38&minQ=1&typeid=39&minQ=1&typeid=40&minQ=1&typeid=11399&minQ=1&typeid=27029&minQ=1&usesystem=30000142

以防万一我没有很好地解释自己(告诉过很多次)一个例子是;

类型| (B) |(S)

34 | 6.32 |19.00

35 | 11.53|22.32

这是当前发生的事情:

foreach 不正确。

替换为

    foreach (XmlNode xnod in Blist)
    {
        XmlNode buyNode = xnod.SelectSingleNode("buy"));
        XmlNode sellNode = xnod.SelectSingleNode("sell"));

        if (xnod.Attributes["id"] != null)
        {
            arr[0] = xnod.Attributes["id"].InnerText;
            arr[1] = buyNode.SelectSingleNode("max").InnerText;
            arr[2] = sellNode.SelectSingleNode("max").InnerText;
        }

        itm = new ListViewItem(arr);
        itm.Font = new Font("Tahima", 9);
        listView1_Jita.Items.Add(itm);  
     }