Components | All | New | MacOS | Windows | Linux | iOS | ||||
Examples | Mac & Win | Server | Client | Guides | Statistic | FMM | Blog | Deprecated | Old |
XML.GetPathValue
Queries value in XML.
Component | Version | macOS | Windows | Linux | Server | iOS SDK |
XML | 7.4 | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |
Parameters
Parameter | Description | Example | Flags |
---|---|---|---|
XML | The XML to process. 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. |
"<test>Hello</test>" | |
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 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 instead.
Examples
Return test node value:
MBS( "XML.GetPathValue"; "<test>Hello</test>"; "test"; 0)
Example result: "Hello"
Query value of attribute:
MBS( "XML.GetPathValue"; "<test id=\"123\">Hello</test>"; "test#id")
Example result: "123"
Query value of node:
MBS( "XML.GetPathValue"; "<outer><inner>Hello</inner></outer>"; "outer.inner")
Example result: "Hello"
Query subtree as XML:
MBS( "XML.GetPathValue"; "<outer><middle><inner>Hello</inner></middle></outer>"; "outer.middle"; 32+4)
Example result:
"<?xml version="1.0" encoding="UTF-8"?>
<middle>
<inner>Hello</inner>
</middle>"
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"; "<people><personid>123</personid><personid>456</personid><personid>789</personid></people>"; "people.personid[2]"; 0)
Example result: "789"
Query items with index in variable:
MBS( "XML.GetPathValue"; "<people><personid>123</personid><personid>456</personid><personid>789</personid></people>"; "people.personid[" & $index & "]"; 0)
Query custom properties of a word file:
# open word file
Set Variable [ $wordfile ; Value: MBS( "WordFile.OpenContainer"; 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"; $WordFile; "custom") ]
#
# get property count
Set Variable [ $count ; Value: MBS( "XML.NodeCount"; $xml; "property" ) ]
#
If [ $count > 0 ]
Set Variable [ $i ; Value: 0 ]
#
Loop
Set Variable [ $name ; Value: MBS( "XML.GetPathValue"; $xml; "Properties.property[" & $i & "]#name"; 1+2 ) ]
Set Variable [ $value ; Value: MBS( "XML.GetPathValue"; $xml; "Properties.property[" & $i & "].lpwstr"; 1+2 ) ]
#
Show Custom Dialog [ "Custom propety" ; $name & ": " & $value ]
#
Set Variable [ $i ; Value: $i + 1 ]
Exit Loop If [ $i >= $count ]
End Loop
#
#
End If
#
# free memory
Set Variable [ $r ; Value: MBS( "WordFile.Release"; $WordFile) ]
See also
- Archive.ExtractFile
- IsError
- WordFile.GetXML
- WordFile.OpenContainer
- WordFile.Release
- XML.NodeCount
- XML.Parse
- XML.Query
- XML.SetPathValue
Release notes
- Version 11.4
- Added possibility to use backslash in XML.GetPathValue to mask dots in xml node names.
- Version 11.2
- Fixed problem with XML.ExtractText and XML.GetPathValue not seeing all text if there are XML nodes within a text block.
- Version 8.1
- Changed XML.GetPathValue to return CDATA section as text if possible.
- Version 7.5
- Added flag 2 to XML.GetPathValue to ignore errors.
- Fixed an issue with XML.GetPathValue not finding right nodes.
- Version 7.4
- Added XML.GetPathValue, XML.DeletePath and XML.SetPathValue functions.
Example Databases
- CURL/Amazon S3/Amazon S3 Upload File
- Encryption and Hash/Read Italian Invoice
- Utility functions/Split DDR
Blog Entries
- MBS FileMaker Advent calendar - Door 14 - XML
- Validating schema for electronic invoices with ZUGFeRD
- Read Invoices from P7M files in Italy
- MBS FileMaker Plugin 11.4 - More than 6500 Functions In One Plugin
- MBS FileMaker Plugin, version 11.4pr5
- MBS FileMaker Plugin, version 11.2pr7
- Query MBS Version from plugin in container
- MBS FileMaker Plugin, version 8.1pr4
- LogicalDOC Webservice
- MBS FileMaker Plugin, version 7.5pr7
FileMaker Magazin
This function checks for a license.
Created 15th September 2017, last changed 27th June 2022
