Brian Dunning's FileMaker Custom Functions

XMLtag ( tag ; content ; type )

To be used in a script, returns correctly indentend xml

  Average rating: 4.8 (22 votes) Log in to vote

Martin Spanjaard   Martin Spanjaard
Trias Digitaal
http://www.triasdigitaal.nl

Share on Facebook Share on Twitter

  Sample input:
XMLtag( "Transaction" ; "" ; "start" )

XMLtag( "FinYear" ; "number=2014" ; "single" )

XMLtag("DueDate" ; "2014-04-03" ; "closed" )
  Sample output:






2014-04-03

  Function definition: (Copy & paste into FileMaker's Edit Custom Function window)

/*************************************************************************************************************************
29-01-2014 - 01-05-2014
© Martin Spanjaard, Trias Digitaal Amserdam

XMLtag( tag ; content ; type ) returns automatically indented, correctly formatted xml-strings.

Some examples of possible output:





2014-04-03

The output ends with a return (¶).

The parameter 'type' can have one of 4 values:

- single: the tag begins with < and ends with />
- end: the tag begins with
- start: the tag begins with < and ends with >
- closed: - if content is given: value,
- if content is empty: (the same as that of the type 'single')

The content for the types 'single' and 'start' should be in the form of a string with one or more name=value pairs.
In the result the values will be quoted: name="value" and immediately follow the tag, as in the examples above.

The type 'end' does not expect content and doesn't handle it if there were content.

---

The correct indentation is done through the variable $xmlindents which is made in this custom function.
It exists during the script calling XMLtag.
The variable contains the number of tabs the code should be indented.
The method is:
- a start-tag raises the indentation with 1,
- an end-tag lowers it with 1.
The other tags do not change the variable.

*************************************************************************************************************************/

 

Comments

Log in to post comments.

 

Note: these functions are not guaranteed or supported by BrianDunning.com. Please contact the individual developer with any questions or problems.

Under construction. Email me your wish list for improvements.