I am trying get c# to select multiple nodes in XML. I'm not sure how to do this here is the xml code followed by c#:
<PackageTrackingInfo> <TrackingNumber>123456789</TrackingNumber> <PackageDestinationLocation> <City>Seattle</City> <StateProvince>WA</StateProvince> <PostalCode>98107</PostalCode> <CountryCode>US</CountryCode> </PackageDestinationLocation> <PackageDeliveryDate> <ScheduledDeliveryDate>2004-09-15</ScheduledDeliveryDate>
And here is c# code:
public string ProcessXML(string xmlRequest)
{
XmlDocument rsp = null;
Saia.Presentation.Website.SaiaSecure.WebService.Shipment.Response response = new Saia.Presentation.Website.SaiaSecure.WebService.Shipment.Response();
string testMode = "";
try
{
if (bool.Parse(WebConfigurationManager.AppSettings["Debug"]) == true)
File.WriteAllText("c:\\temp\\" + DateTime.Now.ToString("MMddyyy_HHmmss") + ".xml", xmlRequest);
// Determine Method to Call
XmlDocument doc = new XmlDocument();
doc.XmlResolver = null;
doc.LoadXml(xmlRequest);
string method = doc.FirstChild.Name;
if (method.ToLower() == "xml")
{
method = doc.FirstChild.NextSibling.Name;
}
if (method == "AmazonTrackingRequest")
{
Saia.Data.General.Shipment prc = new Data.General.Shipment();
string pronum = doc.FirstChild.SelectSingleNode("TrackingNumber").InnerText;
prc.GetByProNumber(decimal.Parse(pronum));
var city = doc.SelectNodes("City");
var state = doc.SelectNodes("State");
var postcode = doc.SelectSingleNode("PostalCode");
...
rsp = new XmlDocument();
}
}
catch (CodeException e)
{
Core.Framework.Debug.CodeException(xmlRequest, e);
}
catch (Exception e)
{
Core.Framework.Debug.Exception(xmlRequest, e);
}
return rsp.InnerXml;
}
}