Topics   All   Mac OS X (Only)   Windows (Only)   Linux (Only, Not)   iOS (Only, Not)  
Components   Crossplatform Mac & Win   Server   Client   Old   Guides   Examples
New in version: 7.1   7.2   7.3   7.4   7.5   8.0   8.1   8.2   8.3   8.4    Statistic  

XML.SetPathXML

Sets path value with XML sub tree.

Component Version macOS Windows Server FileMaker Cloud FileMaker iOS SDK
XML 8.1 Yes Yes Yes Yes Yes

MBS( "XML.SetPathXML"; XML; Path; Flags; NewXML )

Parameters

Parameter Description Example value
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
NewXML The new xml for node or attribute.
Can be XML as text or the reference returned by XML.Parse function, so you can make several times queries to the XML without parsing it each time.
"<name>Christian</name>"

Result

Returns OK or error.

Description

Sets path value with XML sub tree.
If needed, new nodes / attributes are added.
This function uses a path notation like the JSON functions in FileMaker to describe paths. Please point with path to new node.
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.
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

Insert new node:

MBS("XML.SetPathXML"; "<export><person></person></export>"; "export¶person¶name"; 0; "<name>Test</name>")

Example result:
<?xml version="1.0" encoding="UTF-8"?>
<export><person><name>Test</name></person></export>

Insert second node with index:

MBS("XML.SetPathXML"; "<export><person><name>First</name></person></export>"; "export¶person¶name[1]"; 0; "<name>Test</name>")

Example result:
<?xml version="1.0" encoding="UTF-8"?>
<export><person><name>First</name><name>Test</name></person></export>

Append node:

MBS("XML.SetPathXML"; "<export><person><name>First</name></person></export>"; "export¶person¶name[]"; 0; "<name>Test</name>")

See also

Created 2nd February 2018, last changed 2nd February 2018


XML.SetPathValue   -   XML.SetVariables

Feedback: Report problem or ask question.




Links
MBS Xojo Plugins