Click here to Skip to main content
15,895,084 members
Home / Discussions / C#
   

C#

 
QuestionC# and XAML bindings - Need Help with events and dependent Drop Down Lists Pin
Member 133487177-Sep-17 4:45
Member 133487177-Sep-17 4:45 
AnswerRe: C# and XAML bindings - Need Help with events and dependent Drop Down Lists Pin
Mycroft Holmes7-Sep-17 13:20
professionalMycroft Holmes7-Sep-17 13:20 
Questionget more than one string in the checkedlistbox using an array C # Pin
Member 133640086-Sep-17 6:56
Member 133640086-Sep-17 6:56 
SuggestionRe: pegar mais de uma string no checkedlistbox usando um arrayList C# Pin
Richard Deeming6-Sep-17 7:07
mveRichard Deeming6-Sep-17 7:07 
QuestionError on xml.Response Pin
Bootzilla335-Sep-17 21:10
Bootzilla335-Sep-17 21:10 
AnswerRe: Error on xml.Response Pin
OriginalGriff5-Sep-17 21:19
mveOriginalGriff5-Sep-17 21:19 
AnswerRe: Error on xml.Response Pin
Pete O'Hanlon6-Sep-17 0:30
mvePete O'Hanlon6-Sep-17 0:30 
SuggestionRe: Error on xml.Response Pin
Richard Deeming6-Sep-17 6:00
mveRichard Deeming6-Sep-17 6:00 
Since it looks like you're writing new code, rather than maintaining existing code, you might want to consider using LINQ to XML instead:
LINQ to XML Overview (C#) | Microsoft Docs[^]
C#
using System;
using System.Xml.Linq;
using System.Xml.XPath;
 
namespace Shipment_WS_Test_App
{
    static class Class1
    {
        private static readonly XNamespace XsiNamespace = "www.w3.org/2001/XMLSchema-instance";
        
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main(string[] args)
        {
            try
            {
                using (var shipment = new saia.shipment.Shipment())
                {
                    shipment.Timeout = 120000;
                    
                    var request = new XDocument(
                        new XElement("AmazonTrackingRequest",
                            new XAttribute(XNamespace.Xmlns + "xsi", XsiNamespace),
                            new XAttribute(XsiNamespace + "noNamespaceSchemaLocation", "AmazonTrackingRequest.xsd"),
                            new XElement("Validation",
                                new XElement("UserID", "AMZN"),
                                new XElement("Password", "12345")
                            ),
                            new XElement("APIVersion", "4.0"),
                            new XElement("TrackingNumber", "123456789")
                        )
                    );
                    
                    string response = shipment.ProcessXML(request.ToString());
                    if (string.IsNullOrEmpty(response))
                    {
                        Console.WriteLine("No response.");
                    }
                    else
                    {
                        XDocument xmlResponse = XDocument.Parse(response);
                        if (xmlResponse.Root == null)
                        {
                            Console.WriteLine("No response. ({0})", response);
                        }
                        else
                        {
                            XElement responseNode = xmlResponse.Root.Element("Response");
                            if (responseNode == null)
                            {
                                Console.WriteLine("Response element not found. ({0})", xmlResponse);
                            }
                            else if (!string.IsNullOrEmpty((string)responseNode.Element("Code")))
                            {
                                Console.WriteLine(responseNode.Element("Code"));
                                Console.WriteLine(responseNode.Element("Element"));
                                Console.WriteLine(responseNode.Element("Fault"));
                                Console.WriteLine(responseNode.Element("Message"));
                            }
                            else
                            {
                                XElement consigneeNode = responseNode.Element("Consignee");
                                if (consigneeNode == null)
                                {
                                    Console.WriteLine("Consignee element not found. ({0})", responseNode);
                                }
                                else
                                {
                                    Console.WriteLine(consigneeNode.Element("AccountNumber"));
                                    Console.WriteLine(consigneeNode.Element("Address1"));
                                    Console.WriteLine(consigneeNode.Element("Address2"));
                                    Console.WriteLine(consigneeNode.Element("City"));
                                    Console.WriteLine(consigneeNode.Element("State"));
                                    Console.WriteLine(consigneeNode.Element("Zipcode"));
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
                Console.ReadLine();
            }
        }
    }
}




"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer


Questionhow to enable the USB COM Port..? Pin
Member 133808373-Sep-17 21:35
Member 133808373-Sep-17 21:35 
QuestionRe: how to enable the USB COM Port..? Pin
Jochen Arndt3-Sep-17 21:44
professionalJochen Arndt3-Sep-17 21:44 
AnswerRe: how to enable the USB COM Port..? Pin
OriginalGriff3-Sep-17 23:18
mveOriginalGriff3-Sep-17 23:18 
GeneralRe: how to enable the USB COM Port..? Pin
Jochen Arndt3-Sep-17 23:39
professionalJochen Arndt3-Sep-17 23:39 
AnswerRe: how to enable the USB COM Port..? Pin
Jochen Arndt3-Sep-17 23:49
professionalJochen Arndt3-Sep-17 23:49 
Questionbinding datagridview with entity framework Pin
Member 132649363-Sep-17 7:17
Member 132649363-Sep-17 7:17 
AnswerRe: binding datagridview with entity framework Pin
Mycroft Holmes3-Sep-17 22:49
professionalMycroft Holmes3-Sep-17 22:49 
QuestionUpdate listbox items when button is clicked Pin
Mario Lukačić3-Sep-17 2:19
Mario Lukačić3-Sep-17 2:19 
AnswerRe: Update listbox items when button is clicked Pin
Richard MacCutchan3-Sep-17 21:14
mveRichard MacCutchan3-Sep-17 21:14 
GeneralRe: Update listbox items when button is clicked Pin
Mario Lukačić4-Sep-17 2:31
Mario Lukačić4-Sep-17 2:31 
GeneralRe: Update listbox items when button is clicked Pin
Jochen Arndt4-Sep-17 3:49
professionalJochen Arndt4-Sep-17 3:49 
GeneralRe: Update listbox items when button is clicked Pin
Mario Lukačić4-Sep-17 4:01
Mario Lukačić4-Sep-17 4:01 
GeneralRe: Update listbox items when button is clicked Pin
Jochen Arndt4-Sep-17 4:39
professionalJochen Arndt4-Sep-17 4:39 
GeneralRe: Update listbox items when button is clicked Pin
Mario Lukačić4-Sep-17 5:50
Mario Lukačić4-Sep-17 5:50 
GeneralGetting file path and setting to a public variable ?!?! Pin
Mario Lukačić1-Sep-17 8:42
Mario Lukačić1-Sep-17 8:42 
GeneralRe: Getting file path and setting to a public variable ?!?! Pin
Richard Deeming1-Sep-17 9:30
mveRichard Deeming1-Sep-17 9:30 
GeneralRe: Getting file path and setting to a public variable ?!?! Pin
Mario Lukačić1-Sep-17 9:33
Mario Lukačić1-Sep-17 9:33 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.