XML.NodeNames
-------------

Queries list of node names in an XML.

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

MBS( "XML.NodeNames"; XML { ; Recursive; Flags } ) 

**MBS**( **"XML.NodeNames";** /\* Queries list of node names in an XML. \*/  
**$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 queries to the XML without parsing it each time.e.g. "&lt;test&gt;Hello&lt;/test&gt;" \*/   
**$Recursive**; /\* Optional; Whether to recurse in sub tree.  
Pass 1 for rescursive or 0 for non-recursive.  
Default is 0.e.g. 1 \*/   
**$Flags**) /\* Optional; Various Flags.  
Add 1 to ignore errors in xml and continue parsing. This may lead to not everything in the xml being read.  
Add 16 to ignore empty tags. (new in plugin version 7.1)e.g. 0 \*/ 

### Parameters

| Parameter | Description | Example | Flags |
|---|---|---|---|
| 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 queries to the XML without parsing it each time. | "&lt;test&gt;Hello&lt;/test&gt;" |  |
| Recursive | Whether to recurse in sub tree.   Pass 1 for rescursive or 0 for non-recursive.   Default is 0. | 1 | Optional |
| 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 16 to ignore empty tags. (new in plugin version 7.1) | 0 | Optional |

### Result

Returns list or error.

### Description

Queries list of node names in an XML.  
Excludes the root node. The list has no duplicates.  
  
The error "xmlParseEntityRef: no name" means you have an unescaped &amp; in the XML and you should replace it with "&amp;amp;".  
### Examples

Query list of node names:

 MBS ( "XML.NodeNames"; "&lt;Person&gt;&lt;FirstName&gt;Markus&lt;/FirstName&gt;&lt;LastName&gt;Müller&lt;/LastName&gt;&lt;City&gt;New York&lt;/City&gt;&lt;/Person&gt;")  
<small>  
Example result:   
FirstName  
LastName  
City</small>Create records and fill fields with xml values:

 Go to Layout \[“XML Parser”\]  
\# find the node with all the records we need:   
Set Variable \[$oxml ; Value:MBS ( "[XML.SubTree](XMLSubTree.md)"; XML Parser::Input XML; "Body¶GetCategoryProductsResponse" )\]  
\# query number of products   
Set Variable \[$count ; Value:MBS ( "[XML.NodeCount](XMLNodeCount.md)"; $oxml ; "PRODUCT")\]  
\# loop over products   
Set Variable \[$index ; Value:0\]  
Loop  
 # get a product  
 Set Variable \[$xml ; Value:MBS ( "[XML.SubTree](XMLSubTree.md)"; $oxml ; "PRODUCT"; $index )\]  
 # get the names of the XML nodes  
 Set Variable \[$names ; Value:MBS ( "XML.NodeNames"; $xml ; 0; 16)\]  
 # loop over the names  
 Set Variable \[$NameCount ; Value:ValueCount ( $names )\]  
 Set Variable \[$NameIndex ; Value:1\]  
 New Record/Request  
 Loop  
 # Query a value and put it in a field  
 Set Variable \[$name ; Value:GetValue($names ; $NameIndex )\]  
 Set Field By Name \["XML Parser::" &amp; $name ; GetXMLValue( $xml ; $name )\]  
 Set Variable \[$NameIndex ; Value:$NameIndex + 1\]  
 Exit Loop If \[$NameIndex ≥ $NameCount \]  
 End Loop  
 Commit Records/Requests \[No dialog\]  
 Set Variable \[$index ; Value:$index + 1\]  
 Exit Loop If \[$index ≥ $count \]  
End Loop  
### See also

- [XML.NodeCount](XMLNodeCount.md)
- [XML.Parse](XMLParse.md)
- [XML.SubTree](XMLSubTree.md)

### Release notes

- **Version 12.2**
    - Changed [XML.NodeNames](https://www.mbsplugins.eu/XMLNodeNames.shtml) to return names in order of appearance.
- **Version 10.4**
    - Fixed bug in [XML.NodeCount](https://www.mbsplugins.eu/XMLNodeCount.shtml) and [XML.NodeNames](https://www.mbsplugins.eu/XMLNodeNames.shtml), where root node was counted when we had no children.
- **Version 7.1**
    - Added option to [XML.NodeNames](http://www.mbsplugins.eu/XMLNodeNames.shtml) to ignore empty entries.
- **Version 7.0**
    - Added XML helper functions: [XML.ExtractText](http://www.mbsplugins.eu/XMLExtractText.shtml), [XML.NodeNames](http://www.mbsplugins.eu/XMLNodeNames.shtml), [XML.SetVariables](http://www.mbsplugins.eu/XMLSetVariables.shtml), [XML.ListAttributes](http://www.mbsplugins.eu/XMLListAttributes.shtml), XML.HasAttributes, XML.GetAttributes and [XML.SubTree](http://www.mbsplugins.eu/XMLSubTree.shtml).

### Example Databases

- [Utility functions/Split DDR](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/Utility%20functions/Split%20DDR.shtml#1ScriptAnchor_)
- [XML/XML Test](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/XML/XML%20Test.shtml#1ScriptAnchor_)

### Blog Entries

- [MBS FileMaker Plugin, version 12.2pr5](https://www.mbsplugins.de/archive/2022-05-04/MBS_FileMaker_Plugin_version_1/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin, version 10.4pr3](https://www.mbsplugins.de/archive/2020-08-06/MBS_FileMaker_Plugin_version_1/monkeybreadsoftware_blog_filemaker)
- [Split XML for DDR into files for GIT](https://www.mbsplugins.de/archive/2020-07-27/Split_XML_for_DDR_into_files_f/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin, version 7.1pr1](https://www.mbsplugins.de/archive/2017-02-04/MBS_FileMaker_Plugin_version_7/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin, version 7.0pr1](https://www.mbsplugins.de/archive/2017-01-02/MBS_FileMaker_Plugin_version_7/monkeybreadsoftware_blog_filemaker)
- [New XML Functions in MBS FileMaker Plugin](https://www.mbsplugins.de/archive/2016-12-27/New_XML_Functions_in_MBS_FileM/monkeybreadsoftware_blog_filemaker)

### FileMaker Magazin

- [Ausgabe 3/2025, Seite 20](https://filemaker-magazin.de/neuigkeit/4290-Appetithappen-FMM_202503)

This function checks for a license.

Created 25th December 2016 , last changed 9th March 2023

  
[XML.NodeCount](XMLNodeCount.md) - [XML.Parse](XMLParse.md)

[HTML Version](XMLNodeNames.shtml)