Can anyone help point me in the right direction here? Im trying to get new orders and the xml that is returned, I am trying to parse it to extract the order id, the list of items. I am inserting this into a local database for our warehouse management software.
In the sample below, I have highlighted in red what I need to extract. Below that is a crude attempt at extracting the given data.
If anyone could help point me in the right direction that would be greatly appreciated!!
Code:
<?xml version="1.0" encoding="utf-8"?>
<AspDotNetStorefrontImportResult Version="" DateTime="3/4/2007 11:16:40 AM">
<Get Table="Orders" Name="NewOrders" XmlPackage="DumpOrder.xml.config" IDColumn="OrderNumber" DefaultWhereClause="" OrderBy="OrderDate asc">
<Criteria IsNew="1" />
<Order OrderNumber="100000" ShowCardNumber="">
<OrderNumber>100000</OrderNumber>
<OrderGUID>80784eed-ddea-4ef1-adb7-cde7935f775b</OrderGUID>
<ParentOrderNumber>
</ParentOrderNumber>
<StoreVersion>AspDotNetStorefront ML 7.1.0.0/7.0.0.3</StoreVersion>
<QuoteCheckout>0</QuoteCheckout>
<IsNew>1</IsNew>
<ShippedOn>
</ShippedOn>
<CustomerID>58639</CustomerID>
<CustomerGUID>b9672b60-311c-42b5-bb12-8d3b6af81814</CustomerGUID>
<Referrer>
</Referrer>
<SkinID>1</SkinID>
<LastName>Anderson</LastName>
<FirstName>Robert</FirstName>
<Email>admin@aspdotnetstorefront.com</Email>
.
.
.
<OrderItems>
<Item>
<OrderNumber>100000</OrderNumber>
<ShoppingCartRecID>25</ShoppingCartRecID>
<CustomerID>58639</CustomerID>
<ProductID>1</ProductID>
<VariantID>1</VariantID>
<Quantity>1</Quantity>
<ChosenColor />
<ChosenColorSKUModifier />
<ChosenSize />
<ChosenSizeSKUModifier />
<OrderedProductName>Simple Product 1</OrderedProductName>
<OrderedProductVariantName />
<OrderedProductSKU>01-0001</OrderedProductSKU>
<OrderedProductManufacturerPartNumber />
<OrderedProductWeight>0.0000</OrderedProductWeight>
<OrderedProductPrice>4.9500</OrderedProductPrice>
<OrderedProductRegularPrice>4.9500</OrderedProductRegularPrice>
<OrderedProductSalePrice>0.0000</OrderedProductSalePrice>
<OrderedProductExtendedPrice>0.0000</OrderedProductExtendedPrice>
<OrderedProductQuantityDiscountName />
<OrderedProductQuantityDiscountID />
<OrderedProductQuantityDiscountPercent />
<IsTaxable>1</IsTaxable>
<IsShipSeparately>0</IsShipSeparately>
<IsDownload>0</IsDownload>
<DownloadLocation />
<FreeShipping>0</FreeShipping>
<IsSecureAttachment>0</IsSecureAttachment>
<TextOption />
<CartType>0</CartType>
<SubscriptionInterval>0</SubscriptionInterval>
.
.
.
</Order>
</Get>
</AspDotNetStorefrontImportResult>
Code:
private void parseXml(XmlDocument xml)
{
XmlElement root = xml.DocumentElement;
//root.SelectNodes
//XmlNodeList nodesEntries = root.GetElementsByTagName("Order");
XmlNodeList nodesEntries = xml.SelectNodes("/Order/OrderItems");
foreach (XmlNode nodeEntry in nodesEntries)
//for (int i = 0; i < nodesEntries.Count; i++)
{
// string orderNumber = nodeEntry["OrderNumber"].InnerText;
XmlNodeList itemEntries = nodeEntry.SelectNodes("/item");
foreach (XmlNode itemEntry in itemEntries)
{
String orderNumber = itemEntry["OrderNumber"].InnerText;
OutputXml.Text = orderNumber + "/n";
}
//String orderNumber = nodeEntry.SelectSingleNode("item/OrderNumber").InnerText;
// String orderNumber = nodeEntry.SelectSingleNode("OrderNumber").InnerText;
// String baseCharge = nodesEntries[i].InnerXml;
}
}