Components All New MacOS Windows Linux iOS
Examples Mac & Win Server Client Guides Statistic FMM Blog Deprecated Old

XML.Format

Formats XML document.

Component Version macOS Windows Linux Server iOS SDK
XML 6.2 ✅ Yes ✅ Yes ✅ Yes ✅ Yes ✅ Yes
MBS( "XML.Format"; XML { ; Flags } )   More

Parameters

Parameter Description Example Flags
XML The XML to process.
Can be XML as text or the reference returned by XML.Parse function, so you can make several times changes to the XML without parsing it each time.
"<test>Hello</test>"
Flags Various Flags.
Add 1 to ignore errors in xml and continue parsing. This may lead to not everything in the xml being read.
Add 8 to remove all namespaces before query to have queries easier. (new in 6.3)
Add 64 to skip prefix line with xml version.
0 Optional

Result

Returns XML or error.

Description

Formats XML document.
Adds intention and new line characters to format XML for showing too human.
See also XML.Compact to reverse the formatting.

Examples

Format the document:

MBS("XML.Format"; Canonical XML::Input XML; 1)

Format removing namespace:

MBS( "XML.Format"; "<cfdi:Invoice invoiceTotal=\"450.24\"> </cfdi:Invoice>" ; 8)

Check if XML is valid:

MBS( "XML.Format"; "<hello></Hello>";0 )

Example result: [MBS] Failed to parse XML: Opening and ending tag mismatch: hello line 1 and Hello

Format in Auto-Enter calculation:

MBS("XML.Format"; self)

// put this calculation into a field, so the field gets colorized whenever the field is changed and the record gets commited.

Colorize and format in Auto-Enter calculation:

Let ( [
xmlFormatted = MBS("XML.Format"; Self);
xmlFormatFailed = MBS("IsError");
xmlText = If(xmlFormatFailed; Self; xmlFormatted);
result = MBS("XML.Colorize"; xmlText)
]; result )

// put this calculation into a field, so the field gets formated and colorized whenever the field is changed and the record gets commited.

See also

Release notes

  • Version 13.0
  • Version 7.5
    • Improved XML.Format function and xml parsing to better handle blank areas.

Example Databases

Blog Entries

This function checks for a license.

Created 20th May 2016, last changed 28th November 2022


XML.ExtractText - XML.GetAttribute