Class XmlHelper
Contains various functions to perform XML related operations.
Inherited Members
Namespace: Ng911Lib.Utilities
Assembly: Ng911Lib.dll
Syntax
public class XmlHelper
  Properties
| Edit this page View SourcePidfNamespaceTags
Gets an XmlSerializerNamespaces object that maps XML prefix tags to the namespaces for a PIDF-LO XML document.
Declaration
public static XmlSerializerNamespaces PidfNamespaceTags { get; }
  Property Value
| Type | Description | 
|---|---|
| XmlSerializerNamespaces | 
Methods
| Edit this page View SourceDeserializeFromString(string, Type)
Deserializes an XML string into an object.
Declaration
public static object DeserializeFromString(string str, Type ObjType)
  Parameters
| Type | Name | Description | 
|---|---|---|
| string | str | String containing an XML object.  | 
      
| Type | ObjType | Type of the object to deserialize to.  | 
      
Returns
| Type | Description | 
|---|---|
| object | Returns an object of the specified type if successful or null if an error occurred.  | 
      
Remarks
Consider using one of the generic versions of this method because the generic versions eliminate the need for casting.
See Also
| Edit this page View SourceDeserializeFromString<T>(string)
Deserializes an XML string into an object.
Declaration
public static T DeserializeFromString<T>(string str)
  Parameters
| Type | Name | Description | 
|---|---|---|
| string | str | String containing an XML object.  | 
      
Returns
| Type | Description | 
|---|---|
| T | Returns an object of the specified type if successful or null if an error occurred.  | 
      
Type Parameters
| Name | Description | 
|---|---|
| T | Specifies the type of the object to deserialize the XML string into.  | 
      
DeserializeFromString<T>(string, out Exception)
Deserializes an XML string into an object.
Declaration
public static T DeserializeFromString<T>(string str, out Exception Excpt)
  Parameters
| Type | Name | Description | 
|---|---|---|
| string | str | String containing an XML object.  | 
      
| Exception | Excpt | Output. Set to the exception object that was caught. This will be non-null if the return value is null.  | 
      
Returns
| Type | Description | 
|---|---|
| T | Returns an object of the specified type if successful or null if an error occurred.  | 
      
Type Parameters
| Name | Description | 
|---|---|
| T | Specifies the type of the object to deserialize the XML string into.  | 
      
Remarks
Use this version of the method of you need to log and/or troubleshoot XML issues.
GetRootNode(string)
Gets the name of the root node of an XML document.
Declaration
public static XmlNode GetRootNode(string XmlString)
  Parameters
| Type | Name | Description | 
|---|---|---|
| string | XmlString | String containing the XML document.  | 
      
Returns
| Type | Description | 
|---|---|
| XmlNode | Returns the name of the root element or null if an error occurred.  | 
      
SerializePidfToString(object)
Adds the namespaces tag prefixes appropriate for a PIDF-LO XML document and the serializes the object to a string. This method adds the XML tags from the Pidf namespace so it should be used only for the Pidf classes.
Declaration
public static string SerializePidfToString(object Obj)
  Parameters
| Type | Name | Description | 
|---|---|---|
| object | Obj | Input object to serialize.  | 
      
Returns
| Type | Description | 
|---|---|
| string | Returns an XML string if successful or null if an error occurred.  | 
      
SerializeToByteArray(object)
Serializes an object to a byte array that contains the UTF8 characters of an XML document.
Declaration
public static byte[] SerializeToByteArray(object Obj)
  Parameters
| Type | Name | Description | 
|---|---|---|
| object | Obj | Input object to serialize.  | 
      
Returns
| Type | Description | 
|---|---|
| byte[] | Returns a byte array or null if an error occurred during serialization.  | 
      
SerializeToString(object)
Serializes an object into an XML string.
Declaration
public static string SerializeToString(object Obj)
  Parameters
| Type | Name | Description | 
|---|---|---|
| object | Obj | Input object to serialize.  | 
      
Returns
| Type | Description | 
|---|---|
| string | Returns an XML string if successful or null if an error occurred.  | 
      
SerializeToString(object, XmlSerializerNamespaces)
Serializes an object into an XML string. This version adds the name space tag prefixs specified in the Ns parameter.
Declaration
public static string SerializeToString(object Obj, XmlSerializerNamespaces Ns)
  Parameters
| Type | Name | Description | 
|---|---|---|
| object | Obj | Input object to serialize.  | 
      
| XmlSerializerNamespaces | Ns | Contains the tag prefixs and their associated namespaces.  | 
      
Returns
| Type | Description | 
|---|---|
| string | Returns an XML string if successful or null if an error occurred.  |