1
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<imgdir name="Commodity.img">
<imgdir name="0">
<int name="SN" value="10000000"/>
<int name="ItemId" value="1002000"/>
<int name="Count" value="1"/>
<int name="Price" value="300"/>
<int name="Period" value="14"/>
<int name="Priority" value="8"/>
<int name="Gender" value="2"/>
<int name="OnSale" value="0"/>
</imgdir>
<imgdir name="1">
<int name="SN" value="10000001"/>
<int name="ItemId" value="1002015"/>
<int name="Count" value="1"/>
<int name="Price" value="300"/>
<int name="Period" value="14"/>
<int name="Priority" value="8"/>
<int name="Gender" value="2"/>
<int name="OnSale" value="0"/>
</imgdir>
<imgdir name="2">
<int name="SN" value="10000002"/>
<int name="ItemId" value="1002187"/>
<int name="Count" value="1"/>
<int name="Price" value="300"/>
<int name="Period" value="14"/>
<int name="Priority" value="8"/>
<int name="Gender" value="2"/>
<int name="OnSale" value="0"/>
</imgdir>
<imgdir name="3">
<int name="SN" value="10000003"/>
<int name="ItemId" value="1002292"/>
<int name="Count" value="1"/>
<int name="Price" value="300"/>
<int name="Period" value="14"/>
<int name="Priority" value="8"/>
<int name="Gender" value="2"/>
<int name="OnSale" value="0"/>
</imgdir>
이 내가 내 코드에서 얻을 출력이 잘못하고
<?xml version="1.0" encoding="utf-8"?><imgdir xmlns="Commodity.img">
<imgdir SN="10002304" ItemId="5010073" Count="1" Price="3300" Period="90" Priority="12" Gender="2" OnSale="1" xmlns="2" />
<imgdir SN="10002305" ItemId="5010074" Count="1" Price="3300" Period="90" Priority="12" Gender="2" OnSale="1" xmlns="3" />
<imgdir SN="10002306" ItemId="1022104" Count="1" Price="3300" Period="90" Priority="12" Gender="2" OnSale="1" xmlns="4" />
<imgdir SN="10002307" ItemId="9102232" Count="1" Price="16900" Period="90" Priority="12" Gender="2" OnSale="1" xmlns="5" />
<imgdir SN="10002308" ItemId="1003050" Count="1" Price="2500" Period="90" Priority="12" Gender="2" OnSale="1" xmlns="6" />
<imgdir SN="10002309" ItemId="1022102" Count="1" Price="3200" Period="90" Priority="12" Gender="2" OnSale="1" xmlns="7" />
</imgdir>
어떤 제안 무엇을 임? 내 출력
XmlWriter writer = XmlWriter.Create("NewXml.xml");
int number = 0;
string OLD_itemSN = "0";
writer.WriteStartElement("imgdir", "Commodity.img");
foreach (Cashitem item in Cashitems)
{
if (item.OnSale != 0)
{
if (item.SN.ToString() != OLD_itemSN)
{
number++;
OLD_itemSN = item.SN.ToString();
}
writer.WriteStartElement("imgdir", number.ToString());
writer.WriteAttributeString("SN", item.SN.ToString());
writer.WriteAttributeString("ItemId", item.ItemId.ToString());
writer.WriteAttributeString("Count", item.Count.ToString());
writer.WriteAttributeString("Price", item.Price.ToString());
writer.WriteAttributeString("Period", item.Period.ToString());
writer.WriteAttributeString("Priority", item.Priority.ToString());
writer.WriteAttributeString("Gender", item.Gender.ToString());
writer.WriteAttributeString("OnSale", item.OnSale.ToString());
if (item.Limit != null)
{
writer.WriteAttributeString("Limit", item.Limit);
}
writer.WriteEndElement();
}
}
writer.WriteEndElement();
writer.Flush();
}
나는 imgdir 이름 = 값 를 그리워하고 모든 속성 메신저 정말 desperated 전에 :(
이
C# 언어입니까? –