Class Xml (1.41.8)

public class Xml

Beta
XML utilities.

Inheritance

Object > Xml

Static Fields

MEDIA_TYPE

public static final String MEDIA_TYPE

"application/xml; charset=utf-8" media type used as a default for XML parsing.

Use HttpMediaType#equalsIgnoreParameters for comparing media types.

Field Value
TypeDescription
String

Static Methods

createParser()

public static XmlPullParser createParser()

Returns a new XML pull parser.

Returns
TypeDescription
org.xmlpull.v1.XmlPullParser
Exceptions
TypeDescription
org.xmlpull.v1.XmlPullParserException

createSerializer()

public static XmlSerializer createSerializer()

Returns a new XML serializer.

Returns
TypeDescription
org.xmlpull.v1.XmlSerializer

parseElement(XmlPullParser parser, Object destination, XmlNamespaceDictionary namespaceDictionary, Xml.CustomizeParser customizeParser)

public static void parseElement(XmlPullParser parser, Object destination, XmlNamespaceDictionary namespaceDictionary, Xml.CustomizeParser customizeParser)

Parses an XML element using the given XML pull parser into the given destination object.

Requires the current event be XmlPullParser#START_TAG (skipping any initial XmlPullParser#START_DOCUMENT) of the element being parsed. At normal parsing completion, the current event will either be XmlPullParser#END_TAG of the element being parsed, or the XmlPullParser#START_TAG of the requested atom:entry.

Parameters
NameDescription
parserorg.xmlpull.v1.XmlPullParser

XML pull parser

destinationObject

optional destination object to parser into or null to ignore XML content

namespaceDictionaryXmlNamespaceDictionary

XML namespace dictionary to store unknown namespaces

customizeParserXml.CustomizeParser

optional parser customizer or null for none

Exceptions
TypeDescription
IOException
org.xmlpull.v1.XmlPullParserException

toStringOf(Object element)

public static String toStringOf(Object element)

Shows a debug string representation of an element data object of key/value pairs.

It will make up something for the element name and XML namespaces. If those are known, it is better to use XmlNamespaceDictionary#toStringOf(String, Object).

Parameter
NameDescription
elementObject

element data object of key/value pairs (GenericXml, Map, or any object with public fields)

Returns
TypeDescription
String