• Share
    • Twitter
    • LinkedIn
    • Facebook
    • Email
  • Feedback
  • Improve this Doc

Class XmlUtils

The XmlUtils class provides Shared/Static methods for manipulating xml files.

Inheritance
System.Object
XmlUtils
Namespace: DotNetNuke.Common.Utilities
Assembly: DotNetNuke.dll
Syntax
public class XmlUtils : object

Methods

| Improve this Doc View Source

AppendElement(ref XmlDocument, XmlNode, String, String, Boolean, Boolean)

The XmlUtils class provides Shared/Static methods for manipulating xml files.

Declaration
public static void AppendElement(ref XmlDocument objDoc, XmlNode objNode, string attName, string attValue, bool includeIfEmpty, bool cdata)
Parameters
Type Name Description
XmlDocument objDoc
XmlNode objNode
System.String attName
System.String attValue
System.Boolean includeIfEmpty
System.Boolean cdata
| Improve this Doc View Source

AppendElement(ref XmlDocument, XmlNode, String, String, Boolean)

The XmlUtils class provides Shared/Static methods for manipulating xml files.

Declaration
public static void AppendElement(ref XmlDocument objDoc, XmlNode objNode, string attName, string attValue, bool includeIfEmpty)
Parameters
Type Name Description
XmlDocument objDoc
XmlNode objNode
System.String attName
System.String attValue
System.Boolean includeIfEmpty
| Improve this Doc View Source

CreateAttribute(XmlDocument, String, String)

The XmlUtils class provides Shared/Static methods for manipulating xml files.

Declaration
public static XmlAttribute CreateAttribute(XmlDocument objDoc, string attName, string attValue)
Parameters
Type Name Description
XmlDocument objDoc
System.String attName
System.String attValue
Returns
Type Description
XmlAttribute
| Improve this Doc View Source

CreateAttribute(XmlDocument, XmlNode, String, String)

The XmlUtils class provides Shared/Static methods for manipulating xml files.

Declaration
public static void CreateAttribute(XmlDocument objDoc, XmlNode objNode, string attName, string attValue)
Parameters
Type Name Description
XmlDocument objDoc
XmlNode objNode
System.String attName
System.String attValue
| Improve this Doc View Source

CreateCDataElement(XmlDocument, String, String)

The XmlUtils class provides Shared/Static methods for manipulating xml files.

Declaration
public static XmlElement CreateCDataElement(XmlDocument document, string nodeName, string nodeValue)
Parameters
Type Name Description
XmlDocument document
System.String nodeName
System.String nodeValue
Returns
Type Description
XmlElement
| Improve this Doc View Source

CreateElement(XmlDocument, String, String)

The XmlUtils class provides Shared/Static methods for manipulating xml files.

Declaration
public static XmlElement CreateElement(XmlDocument document, string nodeName, string nodeValue)
Parameters
Type Name Description
XmlDocument document
System.String nodeName
System.String nodeValue
Returns
Type Description
XmlElement
| Improve this Doc View Source

Deserialize(Stream, Type)

The XmlUtils class provides Shared/Static methods for manipulating xml files.

Declaration
public static object Deserialize(Stream objStream, Type type)
Parameters
Type Name Description
Stream objStream
Type type
Returns
Type Description
System.Object
| Improve this Doc View Source

DeSerializeDictionary<TValue>(Stream, String)

The XmlUtils class provides Shared/Static methods for manipulating xml files.

Declaration
public static Dictionary<int, TValue> DeSerializeDictionary<TValue>(Stream objStream, string rootname)
Parameters
Type Name Description
Stream objStream
System.String rootname
Returns
Type Description
Dictionary<System.Int32, TValue>
Type Parameters
Name Description
TValue
| Improve this Doc View Source

DeSerializeHashtable(String, String)

The XmlUtils class provides Shared/Static methods for manipulating xml files.

Declaration
public static Hashtable DeSerializeHashtable(string xmlSource, string rootname)
Parameters
Type Name Description
System.String xmlSource
System.String rootname
Returns
Type Description
Hashtable
| Improve this Doc View Source

GetAttributeValue(XPathNavigator, String)

Gets the value of an attribute.

Declaration
public static string GetAttributeValue(XPathNavigator nav, string attributeName)
Parameters
Type Name Description
XPathNavigator nav

Parent XPathNavigator.

System.String attributeName

The name of the Attribute.

Returns
Type Description
System.String

The attribute value.

| Improve this Doc View Source

GetAttributeValueAsBoolean(XPathNavigator, String, Boolean)

The XmlUtils class provides Shared/Static methods for manipulating xml files.

Declaration
public static bool GetAttributeValueAsBoolean(XPathNavigator navigator, string attributeName, bool defaultValue)
Parameters
Type Name Description
XPathNavigator navigator
System.String attributeName
System.Boolean defaultValue
Returns
Type Description
System.Boolean
| Improve this Doc View Source

GetAttributeValueAsInteger(XPathNavigator, String, Int32)

The XmlUtils class provides Shared/Static methods for manipulating xml files.

Declaration
public static int GetAttributeValueAsInteger(XPathNavigator navigator, string attributeName, int defaultValue)
Parameters
Type Name Description
XPathNavigator navigator
System.String attributeName
System.Int32 defaultValue
Returns
Type Description
System.Int32
| Improve this Doc View Source

GetAttributeValueAsLong(XPathNavigator, String, Int64)

The XmlUtils class provides Shared/Static methods for manipulating xml files.

Declaration
public static long GetAttributeValueAsLong(XPathNavigator navigator, string attributeName, long defaultValue)
Parameters
Type Name Description
XPathNavigator navigator
System.String attributeName
System.Int64 defaultValue
Returns
Type Description
System.Int64
| Improve this Doc View Source

GetNodeValue(XmlNode, String, String)

Gets the value of node.

Declaration
public static string GetNodeValue(XmlNode objNode, string nodeName, string defaultValue)
Parameters
Type Name Description
XmlNode objNode

Parent node.

System.String nodeName

Child node to look for.

System.String defaultValue

Default value to return.

Returns
Type Description
System.String

The node value or defaultValue.

Remarks

If the node does not exist or it causes any error the default value will be returned.

| Improve this Doc View Source

GetNodeValue(XmlNode, String)

Gets the value of node.

Declaration
public static string GetNodeValue(XmlNode objNode, string nodeName)
Parameters
Type Name Description
XmlNode objNode

Parent node.

System.String nodeName

Child node to look for.

Returns
Type Description
System.String

The node value or .

Remarks

If the node does not exist or it causes any error the default value will be returned.

| Improve this Doc View Source

GetNodeValue(XPathNavigator, String, String)

Gets the value of a child node as a .

Declaration
public static string GetNodeValue(XPathNavigator navigator, string path, string defaultValue)
Parameters
Type Name Description
XPathNavigator navigator

A navigator pointing to the parent node.

System.String path

An XPath expression to find the child node.

System.String defaultValue

Default value to return if the node doesn't exist or doesn't have a value.

Returns
Type Description
System.String

The value of the node or defaultValue.

| Improve this Doc View Source

GetNodeValue(XPathNavigator, String)

Gets the value of a child node as a .

Declaration
public static string GetNodeValue(XPathNavigator navigator, string path)
Parameters
Type Name Description
XPathNavigator navigator

A navigator pointing to the parent node.

System.String path

An XPath expression to find the child node.

Returns
Type Description
System.String

The value of the node or if the node doesn't exist or doesn't have a value.

| Improve this Doc View Source

GetNodeValueBoolean(XmlNode, String, Boolean)

Gets the value of node.

Declaration
public static bool GetNodeValueBoolean(XmlNode objNode, string nodeName, bool defaultValue)
Parameters
Type Name Description
XmlNode objNode

Parent node.

System.String nodeName

Child node to look for.

System.Boolean defaultValue

Default value to return.

Returns
Type Description
System.Boolean

The node value parsed as a or defaultValue.

Remarks

If the node does not exist or it causes any error the default value will be returned.

| Improve this Doc View Source

GetNodeValueBoolean(XmlNode, String)

Gets the value of node.

Declaration
public static bool GetNodeValueBoolean(XmlNode objNode, string nodeName)
Parameters
Type Name Description
XmlNode objNode

Parent node.

System.String nodeName

Child node to look for.

Returns
Type Description
System.Boolean

The node value parsed as a or false.

Remarks

If the node does not exist or it causes any error the default value (False) will be returned.

| Improve this Doc View Source

GetNodeValueBoolean(XPathNavigator, String, Boolean)

Gets the value of a child node as a .

Declaration
public static bool GetNodeValueBoolean(XPathNavigator navigator, string path, bool defaultValue)
Parameters
Type Name Description
XPathNavigator navigator

A navigator pointing to the parent node.

System.String path

An XPath expression to find the child node.

System.Boolean defaultValue

Default value to return if the node doesn't exist or doesn't have a value.

Returns
Type Description
System.Boolean

The value of the node or defaultValue.

| Improve this Doc View Source

GetNodeValueBoolean(XPathNavigator, String)

Gets the value of a child node as a .

Declaration
public static bool GetNodeValueBoolean(XPathNavigator navigator, string path)
Parameters
Type Name Description
XPathNavigator navigator

A navigator pointing to the parent node.

System.String path

An XPath expression to find the child node.

Returns
Type Description
System.Boolean

The value of the node or false if the node doesn't exist or doesn't have a value.

| Improve this Doc View Source

GetNodeValueDate(XmlNode, String, DateTime)

Gets the value of node.

Declaration
public static DateTime GetNodeValueDate(XmlNode objNode, string nodeName, DateTime defaultValue)
Parameters
Type Name Description
XmlNode objNode

Parent node.

System.String nodeName

Child node to look for.

DateTime defaultValue

Default value to return.

Returns
Type Description
DateTime

The node value parsed as a or defaultValue.

Remarks

If the node does not exist or it causes any error the default value will be returned.

| Improve this Doc View Source

GetNodeValueDate(XPathNavigator, String, DateTime)

Gets the value of a child node as a .

Declaration
public static DateTime GetNodeValueDate(XPathNavigator navigator, string path, DateTime defaultValue)
Parameters
Type Name Description
XPathNavigator navigator

A navigator pointing to the parent node.

System.String path

An XPath expression to find the child node.

DateTime defaultValue

Default value to return if the node doesn't exist or doesn't have a value.

Returns
Type Description
DateTime

The value of the node or defaultValue.

| Improve this Doc View Source

GetNodeValueInt(XmlNode, String, Int32)

Gets the value of node.

Declaration
public static int GetNodeValueInt(XmlNode node, string nodeName, int defaultValue)
Parameters
Type Name Description
XmlNode node

Parent node.

System.String nodeName

Child node to look for.

System.Int32 defaultValue

Default value to return.

Returns
Type Description
System.Int32

The node value parsed as an or defaultValue.

Remarks

If the node does not exist or it causes any error the default value will be returned.

| Improve this Doc View Source

GetNodeValueInt(XmlNode, String)

Gets the value of node.

Declaration
public static int GetNodeValueInt(XmlNode node, string nodeName)
Parameters
Type Name Description
XmlNode node

Parent node.

System.String nodeName

Child node to look for.

Returns
Type Description
System.Int32

The node value parsed as an or 0.

Remarks

If the node does not exist or it causes any error the default value (0) will be returned.

| Improve this Doc View Source

GetNodeValueInt(XPathNavigator, String, Int32)

Gets the value of a child node as an .

Declaration
public static int GetNodeValueInt(XPathNavigator navigator, string path, int defaultValue)
Parameters
Type Name Description
XPathNavigator navigator

A navigator pointing to the parent node.

System.String path

An XPath expression to find the child node.

System.Int32 defaultValue

Default value to return if the node doesn't exist or doesn't have a value.

Returns
Type Description
System.Int32

The value of the node or defaultValue.

| Improve this Doc View Source

GetNodeValueInt(XPathNavigator, String)

Gets the value of a child node as an .

Declaration
public static int GetNodeValueInt(XPathNavigator navigator, string path)
Parameters
Type Name Description
XPathNavigator navigator

A navigator pointing to the parent node.

System.String path

An XPath expression to find the child node.

Returns
Type Description
System.Int32

The value of the node or 0 if the node doesn't exist or doesn't have a value.

| Improve this Doc View Source

GetNodeValueSingle(XmlNode, String, Single)

Gets the value of node.

Declaration
public static float GetNodeValueSingle(XmlNode node, string nodeName, float defaultValue)
Parameters
Type Name Description
XmlNode node

Parent node.

System.String nodeName

Child node to look for.

System.Single defaultValue

Default value to return.

Returns
Type Description
System.Single

The value of the node or defaultValue.

Remarks

If the node does not exist or it causes any error the default value will be returned.

| Improve this Doc View Source

GetNodeValueSingle(XmlNode, String)

Gets the value of node.

Declaration
public static float GetNodeValueSingle(XmlNode node, string nodeName)
Parameters
Type Name Description
XmlNode node

Parent node.

System.String nodeName

Child node to look for.

Returns
Type Description
System.Single

The value of the node or 0 if the node doesn't exist or doesn't have a value.

Remarks

If the node does not exist or it causes any error the default value (0) will be returned.

| Improve this Doc View Source

GetNodeValueSingle(XPathNavigator, String, Single)

Gets the value of a child node as a .

Declaration
public static float GetNodeValueSingle(XPathNavigator navigator, string path, float defaultValue)
Parameters
Type Name Description
XPathNavigator navigator

A navigator pointing to the parent node.

System.String path

An XPath expression to find the child node.

System.Single defaultValue

Default value to return if the node doesn't exist or doesn't have a value.

Returns
Type Description
System.Single

The value of the node or defaultValue.

| Improve this Doc View Source

GetNodeValueSingle(XPathNavigator, String)

Gets the value of a child node as a .

Declaration
public static float GetNodeValueSingle(XPathNavigator navigator, string path)
Parameters
Type Name Description
XPathNavigator navigator

A navigator pointing to the parent node.

System.String path

An XPath expression to find the child node.

Returns
Type Description
System.Single

The value of the node or 0 if the node doesn't exist or doesn't have a value.

| Improve this Doc View Source

GetXMLContent(String)

The XmlUtils class provides Shared/Static methods for manipulating xml files.

Declaration
public static XmlDocument GetXMLContent(string contentUrl)
Parameters
Type Name Description
System.String contentUrl
Returns
Type Description
XmlDocument
| Improve this Doc View Source

GetXmlWriterSettings(ConformanceLevel)

Gets an XmlWriterSettings object.

Declaration
public static XmlWriterSettings GetXmlWriterSettings(ConformanceLevel conformance)
Parameters
Type Name Description
ConformanceLevel conformance

Conformance Level.

Returns
Type Description
XmlWriterSettings

An XmlWriterSettings.

| Improve this Doc View Source

RemoveInvalidXmlCharacters(String)

Removes control characters and other non-UTF-8 characters.

Declaration
public static string RemoveInvalidXmlCharacters(string content)
Parameters
Type Name Description
System.String content

The string to process.

Returns
Type Description
System.String

A string with no control characters or entities above 0x00FD.

| Improve this Doc View Source

Serialize(Object)

The XmlUtils class provides Shared/Static methods for manipulating xml files.

Declaration
public static string Serialize(object obj)
Parameters
Type Name Description
System.Object obj
Returns
Type Description
System.String
| Improve this Doc View Source

SerializeDictionary(IDictionary, String)

The XmlUtils class provides Shared/Static methods for manipulating xml files.

Declaration
public static string SerializeDictionary(IDictionary source, string rootName)
Parameters
Type Name Description
IDictionary source
System.String rootName
Returns
Type Description
System.String
| Improve this Doc View Source

SerializeHashtable(Hashtable, XmlDocument, XmlNode, String, String, String)

The XmlUtils class provides Shared/Static methods for manipulating xml files.

Declaration
public static void SerializeHashtable(Hashtable hashtable, XmlDocument xmlDocument, XmlNode rootNode, string elementName, string keyField, string valueField)
Parameters
Type Name Description
Hashtable hashtable
XmlDocument xmlDocument
XmlNode rootNode
System.String elementName
System.String keyField
System.String valueField
| Improve this Doc View Source

UpdateAttribute(XmlNode, String, String)

The XmlUtils class provides Shared/Static methods for manipulating xml files.

Declaration
public static void UpdateAttribute(XmlNode node, string attName, string attValue)
Parameters
Type Name Description
XmlNode node
System.String attName
System.String attValue
| Improve this Doc View Source

XMLEncode(String)

XML Encodes HTML.

Declaration
public static string XMLEncode(string html)
Parameters
Type Name Description
System.String html

The HTML to encode.

Returns
Type Description
System.String

The XML encoded HTML.

| Improve this Doc View Source

XPathLiteral(String)

Produce an XPath literal equal to the value if possible; if not, produce an XPath expression that will match the value.

Note that this function will produce very long XPath expressions if a value contains a long run of double quotes.

Declaration
public static string XPathLiteral(string value)
Parameters
Type Name Description
System.String value

The value to match.

Returns
Type Description
System.String

If the value contains only single or double quotes, an XPath literal equal to the value. If it contains both, an XPath expression, using concat(), that evaluates to the value.

Remarks

From Stack Overflow (http://stackoverflow.com/a/1352556/2688).

| Improve this Doc View Source

XSLTransform(XmlDocument, ref StreamWriter, String)

The XmlUtils class provides Shared/Static methods for manipulating xml files.

Declaration
public static void XSLTransform(XmlDocument doc, ref StreamWriter writer, string xsltUrl)
Parameters
Type Name Description
XmlDocument doc
StreamWriter writer
System.String xsltUrl

Extension Methods

JsonExtensionsWeb.ToJson(Object)
  • View Source
Back to top by the community, for the community... #DNNCMS