Components | All | New | MacOS | Windows | Linux | iOS | ||||
Examples | Mac & Win | Server | Client | Guides | Statistic | FMM | Blog | Deprecated | Old |
XML.SetPathValue
Sets a xml node.
Component | Version | macOS | Windows | Linux | Server | iOS SDK |
XML | 7.4 | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |
Parameters
Parameter | Description | Example |
---|---|---|
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>" |
Path | The path to the node or attribute to query. | "name" |
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 4 to format returned XML. Add 32 to return result as XML. |
0 |
Value | The new value for node or attribute. This is for passing text to be used in XML and encoded properly. If you pass new value as XML, please use XML.SetPathXML instead!. |
"Hello" |
Result
Returns XML, OK or error.
Description
Sets a xml node.If needed, new nodes / attributes are added.
This function uses a path notation like the JSON functions in FileMaker to describe paths.
You can use name of a node followed by option index in square brackets. On the end you can use # followed by a name of an attribute to select only the attribute. Empty brackets or too big index allow you to append new node in v8.1.
Delimiter between items can be dot like FileMaker or newline.
If you pass in a XML reference number and you do not pass Flag value 32 for returning as XML, we just modify the XML reference in memory. This avoids performance hit for outputting and parsing xml for each change.
Examples
Add a first name:
MBS( "XML.SetPathValue"; "<person/>"; "person.firstName"; 0; "Joe" )
Example result:
"<?xml version="1.0" encoding="UTF-8"?>
<person><firstName>Joe</firstName></person>"
Add id attribute:
MBS( "XML.SetPathValue"; "<person/>"; "person#id"; 0; "123" )
Example result:
"<?xml version="1.0" encoding="UTF-8"?>
<person id="123"/>"
Adds a new name node with href number.
MBS( "XML.SetPathValue"; "<person></person>"; "person.name href=10" ; 4 ; "" )
Example result:
<?xml version="1.0" encoding="UTF-8"?>
<person>
<name href=10></name href=10>
</person>
Encode with entities:
MBS("XML.SetPathValue" ; "<foo/>" ; "foo.bar" ; 0 ; "test & test ¶ < > ")
Example result:
<?xml version="1.0" encoding="UTF-8"?>
<foo><bar>test & test < > </bar></foo>
Adds third item to array:
MBS( "XML.SetPathValue"; "<person><firstName>Joe1</firstName><firstName>Joe2</firstName></person>"; "person.firstName[]"; 0; "Joe3" )
Example result:
<?xml version="1.0" encoding="UTF-8"?>
<person><firstName>Joe1</firstName><firstName>Joe2</firstName><firstName>Joe3</firstName></person>
See also
Release notes
- Version 12.2
- Changed XML.SetPathValue to create text note if needed.
- Version 8.1
- For XML.SetPathValue and XML.SetPathXML you can now specify [] (Without index) to add new node on the end.
- Version 7.4
- Added XML.GetPathValue, XML.DeletePath and XML.SetPathValue functions.
Example Databases
Blog Entries
- MBS FileMaker Plugin, version 12.2pr3
- MBS FileMaker Plugin, version 11.4pr2
- Fun with While function in FileMaker
- MBS FileMaker Plugin, version 8.1pr1
- MBS FileMaker Plugin, version 7.4pr6
This function checks for a license.
Created 16th September 2017, last changed 18th April 2022