C#中,这个XML数据,如何写进数组里?
<?xmlversion='1.0'?><transaction><items><portid>01</portid><cstid>V50050</cstid><eqpi...
<?xml version='1.0' ?>
<transaction>
<items>
<portid>01</portid>
<cstid>V50050</cstid>
<eqpid>BCCA01</eqpid>
<recipeid></recipeid>
<lotid>V5005012345</lotid>
<remain>4</remain>
</items>
<glasses>
<glassid>T00001</glassid>
<slotno>001</slotno>
<glassid>T00002</glassid>
<slotno>002</slotno>
<glassid>T00003</glassid>
<slotno>003</slotno>
<glassid>T00004</glassid>
<slotno>004</slotno>
</glasses>
</transaction> 上面这个XML数据,把ITEMS的内容写进arr[]GLASSES中,GLASS写进arr2[]slotno写进arr3[] 展开
<transaction>
<items>
<portid>01</portid>
<cstid>V50050</cstid>
<eqpid>BCCA01</eqpid>
<recipeid></recipeid>
<lotid>V5005012345</lotid>
<remain>4</remain>
</items>
<glasses>
<glassid>T00001</glassid>
<slotno>001</slotno>
<glassid>T00002</glassid>
<slotno>002</slotno>
<glassid>T00003</glassid>
<slotno>003</slotno>
<glassid>T00004</glassid>
<slotno>004</slotno>
</glasses>
</transaction> 上面这个XML数据,把ITEMS的内容写进arr[]GLASSES中,GLASS写进arr2[]slotno写进arr3[] 展开
2个回答
2013-08-19
展开全部
用dataset、 读取xml 然后在遍历dataset ,放进数组里面。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2013-08-19
展开全部
XmlDocument xd = new XmlDocument();
xd.Load(xmlPath);
int j = xd.SelectSingleNode("transaction/glasses").ChildNodes.Count; Console.WriteLine("glasses childnodes count : " + j);
string[] data = new string[j];
int t = 0;
foreach (XmlNode xn in xd.SelectSingleNode("transaction/glasses").ChildNodes)
{
data[t] = xn.InnerText;
t++;
} for (int k = 0; k < data.Length; k++)
{
if (k % 2 == 0)
{
Console.WriteLine("glassid = " + data[k]);
}
else
{
Console.WriteLine("slotno = " + data[k]);
}
}
xd.Load(xmlPath);
int j = xd.SelectSingleNode("transaction/glasses").ChildNodes.Count; Console.WriteLine("glasses childnodes count : " + j);
string[] data = new string[j];
int t = 0;
foreach (XmlNode xn in xd.SelectSingleNode("transaction/glasses").ChildNodes)
{
data[t] = xn.InnerText;
t++;
} for (int k = 0; k < data.Length; k++)
{
if (k % 2 == 0)
{
Console.WriteLine("glassid = " + data[k]);
}
else
{
Console.WriteLine("slotno = " + data[k]);
}
}
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询