XML.SetPathCData
----------------

Sets path value with CData.

| Component | Version | macOS | Windows | Linux | Server | iOS SDK |
|---|---|---|---|---|---|---|
| [XML](component_XML.md) | [11.1](newinversion111.md) | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |

MBS( "XML.SetPathCData"; XML; Path; Flags; CData ) 

**MBS**( **"XML.SetPathCData";** /\* Sets path value with CData. \*/  
**$XML**; /\* The XML to process.  
Can be XML as text or the reference returned by [XML.Parse](XMLParse.md) function, so you can make several times changes to the XML without parsing it each time.e.g. "&lt;test&gt;Hello&lt;/test&gt;" \*/   
**$Path**; /\* The path to the node or attribute to query.e.g. "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.e.g. 0 \*/   
**$CData**) /\* The new content of CData.e.g. "&lt;b&gt;Hello&lt;/b&gt;" \*/ 

### Parameters

| Parameter | Description | Example |
|---|---|---|
| XML | The XML to process.   Can be XML as text or the reference returned by [XML.Parse](XMLParse.md) function, so you can make several times changes to the XML without parsing it each time. | "&lt;test&gt;Hello&lt;/test&gt;" |
| 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 |
| CData | The new content of CData. | "&lt;b&gt;Hello&lt;/b&gt;" |

### Result

Returns XML, OK or error.

### Description

Sets path value with CData.  
If needed, new nodes / attributes are added.  
This function uses a path notation like the [JSON](component_JSON.md) functions in FileMaker to describe paths. Please point with path to new node.  
You can use name of a node followed by optional 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

Adds a html encoded name:

 MBS ("XML.SetPathCData"; "&lt;export&gt;&lt;person&gt;&lt;/person&gt;&lt;/export&gt;"; "export¶person¶name"; 0; "&lt;b&gt;John Miller&lt;/b&gt;")  
<small>  
Example result:   
&lt;?xml version="1.0" encoding="UTF-8"?&gt;  
&lt;export&gt;&lt;person&gt;&lt;name&gt;&lt;!\[CDATA\[&lt;b&gt;John Miller&lt;/b&gt;\]\]&gt;&lt;/name&gt;&lt;/person&gt;&lt;/export&gt;</small>### See also

- [XML.Parse](XMLParse.md)

### Release notes

- **Version 11.1**
    - Added [XML.SetPathCData](https://www.mbsplugins.eu/XMLSetPathCData.shtml) function.

### Blog Entries

- [MBS FileMaker Plugin 11.1](https://www.mbsplugins.de/archive/2021-03-16/MBS_FileMaker_Plugin_111/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin, version 11.1pr7](https://www.mbsplugins.de/archive/2021-03-01/MBS_FileMaker_Plugin_version_1/monkeybreadsoftware_blog_filemaker)

This function checks for a license.

Created 26th February 2021 , last changed 26th February 2021

  
[XML.ReleaseAll](XMLReleaseAll.md) - [XML.SetPathValue](XMLSetPathValue.md)

[HTML Version](XMLSetPathCData.shtml)