# saxon:parse()

saxon:parse($xml as xs:string) ==> document-node()

This function takes a single argument, a string containing the source text of a well-formed XML document. It returns the document node (root node) that results from parsing this text. It throws an error if the text is not well-formed XML. Applications should not rely on the identity of the returned document node (at present, if the function is called twice with the same arguments, it returns a new document node each time, but this may change in future).

This function is useful where one XML document is embedded inside another using CDATA, or as an alternative way of passing an XML document as a parameter to a stylesheet.

A dynamic error is reported if the supplied string is not well-formed (and namespace-well-formed) XML. An XML declaration may be included, but is not required: if it is present, the encoding declaration will be ignored, since the document is supplied in character form rather than in binary.

The XML parser that is used will be the one nominated to the Saxon `Configuration` as the parser for source documents. Validation against schemas or DTDs, and whitespace stripping, will take place according the settings in the `Configuration` object; if called from XSLT, the `xsl:strip-space` and `xsl:preserve-space` settings in the stylesheet are also taken into account.

Next