F
Francois.P
Guest
Hi, I'm using C# with XElement for the first time and I'm stuck
reading a complexe xml file.
I would like to loop in the detail.
I'm able to read the header information but I cannot figure out how to loop
in the detail.
Thanks.
Francois.
<Order>
<header>
<orderDetail> One
<orderitem> Many
<baseitem>
<reference> Many
<type>RetailCost</type>
<value>000000034.99</value>
</baseitem>
-<orderItem>
<itemKey>1802780013430</itemKey>
-<baseItem>
<itemUid>57921301</itemUid>
<itemTypeCode>Main</itemTypeCode>
-<itemIdentifier>
<itemIdentifierTypeCode>ItemSequenceNumber</itemIdentifierTypeCode>
<itemIdentifierValue>1802780013430</itemIdentifierValue>
</itemIdentifier>
-<itemIdentifier>
<itemIdentifierTypeCode>BuyerNumber</itemIdentifierTypeCode>
<itemIdentifierValue>180278</itemIdentifierValue>
</itemIdentifier>
-<itemIdentifier>
<itemIdentifierTypeCode>ShortDescription</itemIdentifierTypeCode>
<itemIdentifierValue>{RELAXED MEDIUM}{MEDIUM AUTHENTICINDIGO}{34X30}</itemIdentifierValue>
</itemIdentifier>
-<itemIdentifier>
This is part on my detail loop code.
foreach (var orderItem in orderItems)
{
foreach (var podetail in orderItem.Descendants("itemIdentifier").Select(f => new {
itemIdTypeCode = f.Element("itemIdentifierTypeCode").Value,
itemValue = f.Element("itemIdentifierValue").Value
}))
{
switch (podetail.itemIdTypeCode)
{
case "UpcNumber":
Console.WriteLine(" Feature: Upc={0}", podetail.itemValue);
break;
Continue reading...
reading a complexe xml file.
I would like to loop in the detail.
I'm able to read the header information but I cannot figure out how to loop
in the detail.
Thanks.
Francois.
<Order>
<header>
<orderDetail> One
<orderitem> Many
<baseitem>
<reference> Many
<type>RetailCost</type>
<value>000000034.99</value>
</baseitem>
-<orderItem>
<itemKey>1802780013430</itemKey>
-<baseItem>
<itemUid>57921301</itemUid>
<itemTypeCode>Main</itemTypeCode>
-<itemIdentifier>
<itemIdentifierTypeCode>ItemSequenceNumber</itemIdentifierTypeCode>
<itemIdentifierValue>1802780013430</itemIdentifierValue>
</itemIdentifier>
-<itemIdentifier>
<itemIdentifierTypeCode>BuyerNumber</itemIdentifierTypeCode>
<itemIdentifierValue>180278</itemIdentifierValue>
</itemIdentifier>
-<itemIdentifier>
<itemIdentifierTypeCode>ShortDescription</itemIdentifierTypeCode>
<itemIdentifierValue>{RELAXED MEDIUM}{MEDIUM AUTHENTICINDIGO}{34X30}</itemIdentifierValue>
</itemIdentifier>
-<itemIdentifier>
This is part on my detail loop code.
foreach (var orderItem in orderItems)
{
foreach (var podetail in orderItem.Descendants("itemIdentifier").Select(f => new {
itemIdTypeCode = f.Element("itemIdentifierTypeCode").Value,
itemValue = f.Element("itemIdentifierValue").Value
}))
{
switch (podetail.itemIdTypeCode)
{
case "UpcNumber":
Console.WriteLine(" Feature: Upc={0}", podetail.itemValue);
break;
Continue reading...