XML.GetPathValue
----------------

Queries value in XML.

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

MBS( "XML.GetPathValue"; XML; Path { ; Flags } ) 

**MBS**( **"XML.GetPathValue";** /\* Queries value in 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;" \*/   
**$Path**; /\* The path to the node or attribute to query.  
With version 11.4 can include backslashes to escape points in the node name.e.g. "name" \*/   
**$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 2 to return empty text instead of errors.  
Add 4 to format returned XML.  
Add 8 to remove all namespaces before query to have queries easier.   
Add 32 to return result as XML, if it’s more than just a text.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;" |  |
| Path | The path to the node or attribute to query.   With version 11.4 can include backslashes to escape points in the node name. | "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 2 to return empty text instead of errors.   Add 4 to format returned XML.   Add 8 to remove all namespaces before query to have queries easier.    Add 32 to return result as XML, if it’s more than just a text. | 0 | Optional |

### Result

Returns text or error message.

### Description

Queries value in XML.  
This function uses a path notation like the [JSON](component_JSON.md) 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.  
Delimiter between items can be dot like FileMaker or newline.  
  
For more complex queries, you can use [XML.Query](XMLQuery.md) instead.  
### Examples

Return test node value:

 MBS ( "XML.GetPathValue"; "&lt;test&gt;Hello&lt;/test&gt;"; "test"; 0)  
<small>  
Example result: "Hello"</small>Query value of attribute:

 MBS ( "XML.GetPathValue"; "&lt;test id=\\"123\\"&gt;Hello&lt;/test&gt;"; "test#id")  
<small>  
Example result: "123"</small>Query value of node:

 MBS ( "XML.GetPathValue"; "&lt;outer&gt;&lt;inner&gt;Hello&lt;/inner&gt;&lt;/outer&gt;"; "outer.inner")  
<small>  
Example result: "Hello"</small>Query subtree as XML:

 MBS ( "XML.GetPathValue"; "&lt;outer&gt;&lt;middle&gt;&lt;inner&gt;Hello&lt;/inner&gt;&lt;/middle&gt;&lt;/outer&gt;"; "outer.middle"; 32+4)  
<small>  
Example result:   
"&lt;?xml version="1.0" encoding="UTF-8"?&gt;  
&lt;middle&gt;  
 &lt;inner&gt;Hello&lt;/inner&gt;  
&lt;/middle&gt;"</small>Query value from complex XML:

 MBS ("XML.GetPathValue"; XML::BKML\_data ; "bkml.form106AB.data.line1.realProperty.property\[0\].citystatezip";0)  
Query items with index:

 MBS ( "XML.GetPathValue"; "&lt;people&gt;&lt;personid&gt;123&lt;/personid&gt;&lt;personid&gt;456&lt;/personid&gt;&lt;personid&gt;789&lt;/personid&gt;&lt;/people&gt;"; "people.personid\[2\]"; 0)  
<small>  
Example result: "789"</small>Query items with index in variable:

 MBS ( "XML.GetPathValue"; "&lt;people&gt;&lt;personid&gt;123&lt;/personid&gt;&lt;personid&gt;456&lt;/personid&gt;&lt;personid&gt;789&lt;/personid&gt;&lt;/people&gt;"; "people.personid\[" &amp; $index &amp; "\]"; 0)  
Query custom properties of a word file:

 # open word file   
Set Variable \[ $wordfile ; Value: MBS ( "[WordFile.OpenContainer](WordFileOpenContainer.md)"; WordFile::Input ) \]   
If \[ MBS ("ISError") \]   
 Show Custom Dialog \[ "Error" ; $wordFile \]   
 Exit Script \[ Text Result: \]   
End If  
\#   
\# read xml   
Set Variable \[ $xml ; Value: MBS ( "[WordFile.GetXML](WordFileGetXML.md)"; $WordFile ; "custom") \]   
\#   
\# get property count   
Set Variable \[ $count ; Value: MBS ( "[XML.NodeCount](XMLNodeCount.md)"; $xml ; "property" ) \]   
\#   
If \[ $count &gt; 0 \]   
 Set Variable \[ $i ; Value: 0 \]   
 #   
 Loop  
 Set Variable \[ $name ; Value: MBS ( "XML.GetPathValue"; $xml ; "Properties.property\[" &amp; $i &amp; "\]#name"; 1+2 ) \]   
 Set Variable \[ $value ; Value: MBS ( "XML.GetPathValue"; $xml ; "Properties.property\[" &amp; $i &amp; "\].lpwstr"; 1+2 ) \]   
 #   
 Show Custom Dialog \[ "Custom propety" ; $name &amp; ": " &amp; $value \]   
 #   
 Set Variable \[ $i ; Value: $i + 1 \]   
 Exit Loop If \[ $i &gt;= $count \]   
 End Loop  
 #   
 #   
End If  
\#   
\# free memory   
Set Variable \[ $r ; Value: MBS ( "[WordFile.Release](WordFileRelease.md)"; $WordFile ) \]  
### See also

- [Archive.ExtractFile](ArchiveExtractFile.md)
- [IsError](IsError.md)
- [WordFile.GetXML](WordFileGetXML.md)
- [WordFile.OpenContainer](WordFileOpenContainer.md)
- [WordFile.Release](WordFileRelease.md)
- [XML.NodeCount](XMLNodeCount.md)
- [XML.Parse](XMLParse.md)
- [XML.Query](XMLQuery.md)
- [XML.SetPathValue](XMLSetPathValue.md)

### Release notes

- **Version 15.1**
    - Fixed a problem with [XML.GetPathValue](https://www.mbsplugins.eu/XMLGetPathValue.shtml) function crashing with name spaces, broken in 15.0.
- **Version 11.4**
    - Added possibility to use backslash in [XML.GetPathValue](https://www.mbsplugins.eu/XMLGetPathValue.shtml) to mask dots in xml node names.
- **Version 11.2**
    - Fixed problem with [XML.ExtractText](https://www.mbsplugins.eu/XMLExtractText.shtml) and [XML.GetPathValue](https://www.mbsplugins.eu/XMLGetPathValue.shtml) not seeing all text if there are XML nodes within a text block.
- **Version 8.1**
    - Changed [XML.GetPathValue](http://www.mbsplugins.eu/XMLGetPathValue.shtml) to return CDATA section as text if possible.
- **Version 7.5**
    - Added flag 2 to [XML.GetPathValue](http://www.mbsplugins.eu/XMLGetPathValue.shtml) to ignore errors.
    - Fixed an issue with [XML.GetPathValue](http://www.mbsplugins.eu/XMLGetPathValue.shtml) not finding right nodes.
- **Version 7.4**
    - Added [XML.GetPathValue](http://www.mbsplugins.eu/XMLGetPathValue.shtml), [XML.DeletePath](http://www.mbsplugins.eu/XMLDeletePath.shtml) and [XML.SetPathValue](http://www.mbsplugins.eu/XMLSetPathValue.shtml) functions.

### Example Databases

- [CURL/Amazon S3/Amazon S3 Upload File](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/CURL/Amazon%20S3/Amazon%20S3%20Upload%20File.shtml#9ScriptAnchor_)
- [Encryption and Hash/Read Italian Invoice](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/Encryption%20and%20Hash/Read%20Italian%20Invoice.shtml#1ScriptAnchor_)
- [Utility functions/Split DDR](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/Utility%20functions/Split%20DDR.shtml#2ScriptAnchor_)

### Blog Entries

- [Electronic invoices in FileMaker](https://www.mbsplugins.de/archive/2025-03-06/Electronic_invoices_in_FileMak/monkeybreadsoftware_blog_filemaker)
- [Elektronische Rechnungen in FileMaker](https://www.mbsplugins.de/archive/2025-03-04/Elektronische_Rechnungen_in_Fi/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin, version 15.1pr5](https://www.mbsplugins.de/archive/2025-02-24/MBS_FileMaker_Plugin_version_1/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Advent calendar - Door 14 - XML](https://www.mbsplugins.de/archive/2024-12-14/MBS_FileMaker_Advent_calendar_/monkeybreadsoftware_blog_filemaker)
- [Validating schema for electronic invoices with ZUGFeRD](https://www.mbsplugins.de/archive/2024-10-11/Validating_schema_for_electron/monkeybreadsoftware_blog_filemaker)
- [Read Invoices from P7M files in Italy](https://www.mbsplugins.de/archive/2024-03-24/Read_Invoices_from_P7M_files_i/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin 11.4 - More than 6500 Functions In One Plugin](https://www.mbsplugins.de/archive/2021-09-07/MBS_FileMaker_Plugin_114_-_Mor/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin, version 11.4pr5](https://www.mbsplugins.de/archive/2021-09-03/MBS_FileMaker_Plugin_version_1/monkeybreadsoftware_blog_filemaker)
- [Query MBS Version from plugin in container](https://www.mbsplugins.de/archive/2021-04-19/Query_MBS_Version_from_plugin_/monkeybreadsoftware_blog_filemaker)
- [LogicalDOC Webservice](https://www.mbsplugins.de/archive/2017-12-27/LogicalDOC_Webservice/monkeybreadsoftware_blog_filemaker)

### FileMaker Magazin

- [Ausgabe 3/2025, Seite 19 bis 20](https://filemaker-magazin.de/neuigkeit/4290-Appetithappen-FMM_202503)
- [Ausgabe 6/2022, Seite 26](https://filemaker-magazin.de/neuigkeit/4206-Appetithappen-FMM_202206)

This function checks for a license.

Created 15th September 2017 , last changed 27th June 2022

  
[XML.GetAttribute](XMLGetAttribute.md) - [XML.GetSaveNoEmptyTags](XMLGetSaveNoEmptyTags.md)

[HTML Version](XMLGetPathValue.shtml)