Table of Contents

Class XmlUtil

Namespace
SunamoXliffParser
Assembly
SunamoXliffParser.dll

Provides utility methods for working with XML elements and attributes.

public static class XmlUtil
Inheritance
XmlUtil
Inherited Members

Methods

DeNormalizeLineBreaks(string)

Restores standard Windows line breaks by replacing lone newlines with carriage return + newline pairs.

public static string DeNormalizeLineBreaks(string text)

Parameters

text string

The text to de-normalize.

Returns

string

The text with Windows-style line breaks, or an empty string if the input is null or whitespace.

GetAttributeIfExists(XElement, string)

Gets the value of an attribute if it exists on the specified element.

public static string GetAttributeIfExists(XElement node, string name)

Parameters

node XElement

The XML element to inspect.

name string

The name of the attribute to retrieve.

Returns

string

The attribute value, or an empty string if the attribute does not exist.

GetIntAttributeIfExists(XElement, string)

Gets the integer value of an attribute if it exists on the specified element.

public static int GetIntAttributeIfExists(XElement node, string name)

Parameters

node XElement

The XML element to inspect.

name string

The name of the attribute to retrieve.

Returns

int

The parsed integer value, or 0 if the attribute does not exist.

NormalizeLineBreaks(string)

Normalizes line breaks by removing carriage return characters.

public static string NormalizeLineBreaks(string text)

Parameters

text string

The text to normalize.

Returns

string

The text with carriage returns removed, or an empty string if the input is null or whitespace.