Show / Hide Table of Contents

Class XmlExtensions

Contains functionality to map JSON values to XML constructs.

Inheritance
System.Object
XmlExtensions
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Namespace: Manatee.Json
Assembly: Manatee.Json.dll
Syntax
public static class XmlExtensions

Methods

| Improve this Doc View Source

ToJson(IEnumerable<XElement>)

Converts an System.Xml.Linq.XElement to a JsonObject.

Declaration
public static JsonValue ToJson(this IEnumerable<XElement> xElements)
Parameters
Type Name Description
System.Collections.Generic.IEnumerable<System.Xml.Linq.XElement> xElements

A collection of System.Xml.Linq.XElement objects.

Returns
Type Description
JsonValue

A single JsonValue which represents the list of System.Xml.Linq.XElement objects.

Exceptions
Type Condition
System.Xml.XmlException

Thrown if an error occurs while attempting to convert an array of elements.

| Improve this Doc View Source

ToJson(XElement)

Converts an System.Xml.Linq.XElement to a JsonObject.

Declaration
public static JsonValue ToJson(this XElement xElement)
Parameters
Type Name Description
System.Xml.Linq.XElement xElement

An System.Xml.Linq.XElement.

Returns
Type Description
JsonValue

The JsonValue representation of the System.Xml.Linq.XElement.

| Improve this Doc View Source

ToXElement(JsonValue, String)

Converts a JsonValue to an XElement

Declaration
public static XElement ToXElement(this JsonValue json, string key)
Parameters
Type Name Description
JsonValue json

A JsonValue.

System.String key

The key to be used as a top-level element name.

Returns
Type Description
System.Xml.Linq.XElement

An System.Xml.Linq.XElement representation of the JsonValue.

Remarks

The 'key' parameter may be null only when the underlying JSON is an object which contains a single key/value pair.

Exceptions
Type Condition
System.ArgumentException

Thrown if key is null, empty, or whitespace and json is not a non-empty JsonObject.

  • Improve this Doc
  • View Source
Back to top Generated by DocFX