Hi All,
I'm trying to read an XML data in to my c# object i am recieving a null values please find the code below and my XML output
private LogisticsReport GetLogisticsReport()
{
int StoreId = 00316;
try
{
XmlDocument xmlDoc = new XmlDocument();
string LogisticsReportResponseXml = _reportService.GetLogisticsReportInfo(StoreId).Result;
xmlDoc.LoadXml(LogisticsReportResponseXml);
var logisticsReport = new LogisticsReport();
//check for a an "error" node within the results
XmlNamespaceManager nsmgr = new XmlNamespaceManager(xmlDoc.NameTable);
nsmgr.AddNamespace("ns", "http://wsdev.truserv.com/oraclewebservice/oraclemdb.asmx");
XmlNode resultNode = xmlDoc.SelectSingleNode("results", nsmgr);
XmlNode userNode = resultNode.SelectSingleNode("logistics", nsmgr);
if (userNode != null)
{
logisticsReport.FreightRate = userNode.Attributes["freightrate"] != null ? userNode.Attributes["freightrate"].Value : string.Empty;
logisticsReport.OffShoreDelivery = userNode.Attributes["offshoredelivery"] != null ? userNode.Attributes["offshoredelivery"].Value : string.Empty;
logisticsReport.StartCode = userNode.Attributes["stratcode"] != null ? userNode.Attributes["stratcode"].Value : string.Empty;
logisticsReport.MultipleDelivery = userNode.Attributes["multipledelivery"] != null ? userNode.Attributes["multipledelivery"].Value : string.Empty;
logisticsReport.Palletized = userNode.Attributes["palletized"] != null ? userNode.Attributes["palletized"].Value : string.Empty;
logisticsReport.TotesShipped = userNode.Attributes["totesshipped"] != null ? userNode.Attributes["totesshipped"].Value : string.Empty;
logisticsReport.TotesReturned = userNode.Attributes["totesreturned"] != null ? userNode.Attributes["totesreturned"].Value : string.Empty;
logisticsReport.TotesLastDate = userNode.Attributes["toteslastdate"] != null ? userNode.Attributes["toteslastdate"].Value : string.Empty;
logisticsReport.ContainerShipped = userNode.Attributes["containersshipped"] != null ? userNode.Attributes["containersshipped"].Value : string.Empty;
logisticsReport.ContainersReturned = userNode.Attributes["containersreturned"] != null ? userNode.Attributes["containersreturned"].Value : string.Empty;
logisticsReport.ContainersLastDate = userNode.Attributes["containerslastdate"] != null ? userNode.Attributes["containerslastdate"].Value : string.Empty;
}
return logisticsReport;
}
catch (Exception ex)
{
throw ex;
}
}
XML OutPut <results>
<response mode="all" value=""/>
<logistics>
<freight
rdc1="01 - HARVARD"
rdc2="01 - HARVARD"
freightrate="0 %"
offshoredelivery ="Y"
stratcode="Y"
multipledelivery="N"
palletized="N"
totesshipped="0"
totesreturned="0"
toteslastdate="5/30/2001 12:00:00 AM"
containersshipped="0"
containersreturned="0"
containerslastdate="5/30/2001 12:00:00 AM"/>
<routes/>
</logistics>
</results>
Appreciate your response.
Thanks in Advance
Join Hands Change lives
Thanks & Regards
Straight Edge Society