Options

Options -- List of all XML_Beautifier options

Introduction to options

Options let you influence the beautifiying process. They are passed to the renderer and thus, you have to check, whether the renderer you are using supports the options you want to use.

As there currently is only one renderer (Plain) available, you should not worry about this too much.

Options can be passed as an associative array to the constructor of XML_Beautifier. You may also use setOption(), or setOptions() to set one or more options after the instance of XML_Beautifier has been created.

All available options

Here is a list of all options supported by XML_Beautifier.

Table 61-1. XML_Beautifier options

OptionPossible valuesDefaultDescription
removeLineBreaksTRUE or FALSETRUESets, whether linebreaks should be stripped from cdata sections
indentany string" " (4 spaces)The string passed to this option will be used to indent the tags in one level.
linebreakany string"\n"The string passed to this option will be used for linebreaks You should use "\n" or "\r\n".
caseFoldingTRUE or FALSEFALSEDisable or enable case folding for tags and attributes
caseFoldingTo"uppercase" or "lowercase""uppercase"Can be used, if caseFolding is set to TRUE to define whether tags and attributes should be converted to upper- or lowercase
normalizeCommentsFALSE or TRUEFALSEIf set to true, all adjacent whitespaces in an XML comment will be converted to one space. This will convert comments with more than one line to a comment with one line.
maxCommentLineinteger-1Maximum length of comment line. If a comment exceeds this limit, it will be wrapped automatically. If set to -1 the line length is unlimited.
multilineTagsTRUE or FALSEFALSEIf set to true, a linebreak will be added inside the tags after each attribute and attributes will be indeted.

Options example

The following example shows how to set options for XML_Beautifier.

Options example setting options at a later point

The following example shows how to set options for XML_Beautifier, if the instance already has been created.