Help Center

Local Navigation

Object: XMLSerializer

Availability

BlackBerry® Device Software version 4.7.1 or later

The XMLSerializer object provides the serializeToString() method, which converts an XML document or subtree into a string.

XMLSerializer methods

Method name

Description

Availability

serializeToString()

Converts an XML document or subtree into a string.

4.7.1 or later

Method: XMLSerializer.serializeToString()

Availability

BlackBerry® Device Software version 4.7.1 or later

The serialToString() method converts an XML document or subtree into a string.

Syntax

XMLSerializer.serializeToString( xmlDocument )

Parameters

Parameter

Type

Description

xmlDocument

Node

Specifies the XML document or subtree to convert.

Return values

This method returns a string representation of the given XML document or subtree.

Exceptions

Exception

Description

TYPE_MISMATCH_ERR

Thrown if xmlDocument is null.

Code sample: Converting a string into XML and back to a string again

var xmlString = "<?xml version='1.0' ?>\
<root>\
	<level1>\
		<option>Option1</option>\
		<option>Option2</option>\
		<option>Option3</option>\
	</level1>\
</root>";

var parser = new DOMParser();
var xmlDocument = parser.parseFromString( xmlString, "text/xml" );

var serializer = new XMLSerializer();
var string = serializer.serializeToString( xmlDocument ); 
alert( string )
Next topic: Glossary

Was this information helpful? Send us your comments.