Не понимаю почему,но не загружает весь xml файл. Всего загружает 21 итем. Если убрать 21 итем,будет загружать 19 итемов.
XML-Моделька:
<?xml version="1.0" encoding="utf-8" ?>
<List>
<Item Id="10000001" Item="500010003" Credits="0" Points="1" Quantity="100" Type="1" StockType="1" ItemType="0"/>
<Item Id="10000002" Item="601002011" Credits="0" Points="1" Quantity="100" Type="1" StockType="2" ItemType="1"/>
<Item Id="10000003" Item="702001017" Credits="0" Points="1" Quantity="100" Type="1" StockType="0" ItemType="2"/>
<Item Id="10000004" Item="803007001" Credits="0" Points="1" Quantity="100" Type="1" StockType="0" ItemType="3"/>
<Item Id="10000005" Item="904007007" Credits="0" Points="1" Quantity="100" Type="1" StockType="0" ItemType="4"/>
<Item Id="10000006" Item="1001001003" Credits="0" Points="1" Quantity="100" Type="1" StockType="0" ItemType="5"/>
<Item Id="10000007" Item="1001001004" Credits="0" Points="1" Quantity="100" Type="1" StockType="0" ItemType="6"/>
<Item Id="10000008" Item="1104003003" Credits="0" Points="1" Quantity="100" Type="1" StockType="0" ItemType="7"/>
<Item Id="10000009" Item="1006001032" Credits="0" Points="1" Quantity="100" Type="1" StockType="0" ItemType="8"/>
<Item Id="10000010" Item="1103003010" Credits="0" Points="1" Quantity="100" Type="1" StockType="0" ItemType="9"/>
<Item Id="10000011" Item="1200026000" Credits="0" Points="1" Quantity="1440" Type="2" StockType="1" ItemType="10"/>
<Item Id="10000012" Item="1200007000" Credits="0" Points="1" Quantity="1440" Type="2" StockType="1" ItemType="10"/>
<Item Id="10000013" Item="1103003003" Credits="0" Points="1" Quantity="1440" Type="2" StockType="1" ItemType="9"/>
<item Id="10000014" Item="1001001033" Credits="0" Points="1" Quantity="100" Type="1" StockType="2" ItemType="6"/>
<Item Id="10000015" Item="300005032" Credits="150" Points="0" Quantity="300" Type="3" StockType="1" ItemType="0"/>
<Item Id="10000016" Item="300005030" Credits="150" Points="0" Quantity="300" Type="3" StockType="1" ItemType="0"/>
<Item Id="10000017" Item="300005023" Credits="150" Points="0" Quantity="300" Type="3" StockType="1" ItemType="0"/>
<Item Id="10000018" Item="100003063" Credits="50" Points="0" Quantity="300" Type="3" StockType="1" ItemType="0"/>
<Item Id="10000019" Item="400006005" Credits="0" Points="65000" Quantity="300" Type="3" StockType="1" ItemType="0"/>
<Item Id="10000020" Item="601002007" Credits="0" Points="16000" Quantity="100" Type="1" StockType="2" ItemType="1"/>
</List>
Парсер:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Xml;
using Core.Model;
namespace Core.Data.Parsers
{
public class GoodsParser
{
public static Dictionary<int, Good> goods = new Dictionary<int, Good>();
public static void Load()
{
String path = "Data//Goods.xml";
XmlDocument xmlDocument = new XmlDocument();
FileStream fileStream = new FileStream(path, FileMode.Open);
if (fileStream.Length != 0L)
{
try
{
xmlDocument.Load((Stream)fileStream);
for (XmlNode xmlNode1 = xmlDocument.FirstChild; xmlNode1 != null; xmlNode1 = xmlNode1.NextSibling)
{
if ("List".Equals(xmlNode1.Name))
{
for (XmlNode xmlNode2 = xmlNode1.FirstChild; xmlNode2 != null; xmlNode2 = xmlNode2.NextSibling)
{
if ("Item".Equals(xmlNode2.Name))
{
XmlNamedNodeMap xmlNamedNodeMap = xmlNode2.Attributes;
Good good = new Good
{
good_id = int.Parse(xmlNamedNodeMap.GetNamedItem("Id").Value),
item_id = int.Parse(xmlNamedNodeMap.GetNamedItem("Item").Value),
priceCredits = int.Parse(xmlNamedNodeMap.GetNamedItem("Credits").Value),
pricePoints = int.Parse(xmlNamedNodeMap.GetNamedItem("Points").Value),
quantity = int.Parse(xmlNamedNodeMap.GetNamedItem("Quantity").Value),
type = int.Parse(xmlNamedNodeMap.GetNamedItem("Type").Value),
stockType = int.Parse(xmlNamedNodeMap.GetNamedItem("StockType").Value),
ItemType = int.Parse(xmlNamedNodeMap.GetNamedItem("ItemType").Value),
};
goods.Add(good.getGoodId(), good);
}
}
}
}
Logger.Info("[Shop] Loaded {0} goods", goods.Count);
}
catch (XmlException ex)
{
Logger.Info("Error {0}", ex);
}
fileStream.Close();
}
}
}
}