Table of Contents

Class XmlGeneratorNS2

Namespace
SunamoXml.Generators
Assembly
SunamoXml.dll

Builds namespaced XML content. All generated tags are prefixed with the specified namespace.

public class XmlGeneratorNS2
Inheritance
XmlGeneratorNS2
Inherited Members
Extension Methods

Constructors

XmlGeneratorNS2(string)

Initializes a new instance with the specified namespace prefix.

public XmlGeneratorNS2(string xmlNamespace)

Parameters

xmlNamespace string

The namespace prefix to prepend to all tags.

Fields

stringBuilder

The underlying StringBuilder that holds the generated XML content.

protected StringBuilder stringBuilder

Field Value

StringBuilder

Methods

TerminateTag(string)

Writes a closing tag for the specified element.

public void TerminateTag(string tagName)

Parameters

tagName string

The element name to close.

ToString()

Returns the generated XML content as a string with normalized spacing.

public override string ToString()

Returns

string

WriteCData(string)

Writes a CDATA section with the specified content.

public void WriteCData(string innerCData)

Parameters

innerCData string

The content to wrap in CDATA.

WriteElement(string, string)

Writes a complete element with the specified inner content.

public void WriteElement(string elementName, string inner)

Parameters

elementName string

The element name.

inner string

The inner content of the element.

WriteElementCData(string, string)

Writes a complete element with the inner content wrapped in a CDATA section.

public void WriteElementCData(string elementName, string cdata)

Parameters

elementName string

The element name.

cdata string

The content to wrap in CDATA.

WriteElementObject(string, object)

Writes a complete element with the object's string representation as inner content. Skips if the value is null.

public void WriteElementObject(string elementName, object value)

Parameters

elementName string

The element name.

value object

The object whose string representation becomes the inner content.

WriteRaw(string)

Writes raw content directly to the output.

public void WriteRaw(string rawContent)

Parameters

rawContent string

The raw content to append.

WriteSimpleTag(string)

Writes a self-closing tag without attributes.

public void WriteSimpleTag(string tagName)

Parameters

tagName string

The element name.

WriteSimpleTag(string, params string[])

Writes a self-closing tag with multiple attributes.

public void WriteSimpleTag(string tagName, params string[] attributes)

Parameters

tagName string

The element name.

attributes string[]

Alternating attribute names and values.

WriteSimpleTagS(string, string, params string[])

Creates a self-closing tag string with the specified namespace, tag name, and optional attributes.

public static string WriteSimpleTagS(string xmlNamespace, string tagName, params string[] attributes)

Parameters

xmlNamespace string

The namespace prefix.

tagName string

The element name.

attributes string[]

Alternating attribute names and values.

Returns

string

WriteTag(string)

Writes an opening tag for the specified element.

public void WriteTag(string tagName)

Parameters

tagName string

The element name.

WriteTagWith2Attrs(string, string, string, string, string)

Writes an opening tag with two attributes.

public void WriteTagWith2Attrs(string tagName, string firstName, string firstValue, string secondName, string secondValue)

Parameters

tagName string

The element name.

firstName string

The first attribute name.

firstValue string

The first attribute value.

secondName string

The second attribute name.

secondValue string

The second attribute value.

WriteTagWithAttr(string, string, string)

Writes an opening tag with one attribute.

public void WriteTagWithAttr(string tagName, string attributeName, string attributeValue)

Parameters

tagName string

The element name.

attributeName string

The attribute name.

attributeValue string

The attribute value.

WriteTagWithAttrs(string, params string[])

Writes an opening tag with multiple attributes.

public void WriteTagWithAttrs(string tagName, params string[] attributes)

Parameters

tagName string

The element name.

attributes string[]

Alternating attribute names and values.

WriteXmlDeclaration()

Writes the standard XML declaration to the output.

public void WriteXmlDeclaration()