CaseMap Server

CaseMap Server Helper Methods

CaseMap Server Helper Methods

Previous topic Next topic No directory for this topic No expanding text in this topic  

CaseMap Server Helper Methods

Previous topic Next topic Topic directory requires JavaScript JavaScript is required for expanding text JavaScript is required for the print function Mail us feedback on this topic!  

The following methods are used in the code samples throughout this reference.

 

DisplayMethod

This method displays the return codes and XML body of a message. DisplayMethod is used by all methods to display the returned messages.

 

using System.Xml;

using System.Xml.XPath;

 

public static void DisplayMessage(HttpWebResponse response)

{

  //Write out the status code number and name

  Console.WriteLine((int)response.StatusCode + " " + response.StatusCode);

 

  //stream the body of the message into an XML reader.

  XmlTextReader reader = new XmlTextReader(response.GetResponseStream());

  reader.WhitespaceHandling = WhitespaceHandling.None;

 

  //try to load the XML into an XML doc and display it.

  XmlDocument xd = new XmlDocument();

     try

        {

           xd.Load(reader);

          XmlNode xnodDE = xd.DocumentElement;

 

           ChildDisplay(xnodDE, 0);

           reader.Close();

         }

      //if anything goes wrong, return.

      catch

         {

            return;

         }

}

 

private static void ChildDisplay(XmlNode xnod, int level)

{

  XmlNode xnodWorking;

  String pad = new String(' ', level * 2);

 

  Console.WriteLine(pad + xnod.Name + "(" + xnod.NodeType.ToString() + ": " + xnod.Value + ")");

 

  if (xnod.NodeType == XmlNodeType.Element)

   {

      XmlNamedNodeMap mapAttributes = xnod.Attributes;

      for (int i = 0; i < mapAttributes.Count; i++)

       {

          Console.WriteLine(pad + " " + mapAttributes.Item(i).Name + " = " + mapAttributes.Item(i).Value);

       }

   }

 

  if (xnod.HasChildNodes)

   {

       xnodWorking = xnod.FirstChild;

      while (xnodWorking != null)

       {

           ChildDisplay(xnodWorking, level + 1);

           xnodWorking = xnodWorking.NextSibling;

       }

   }

}