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

XML.NodeNames

Queries list of node names in an XML.

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

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

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 queries to the XML without parsing it each time.
"<test>Hello</test>"
recursive Optional
Whether to recurse in sub tree.
Pass 1 for rescursive or 0 for non-recursive.
Default is 0.
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)
0

Result

Returns list or error.

Description

Queries list of node names in an XML.
Excludes the root node. The list has no duplicates.

Examples

Query list of node names:

MBS( "XML.NodeNames"; "<Person><FirstName>Markus</FirstName><LastName>Müller</LastName><City>New York</City></Person>")

Example result:
FirstName
LastName
City

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"; XML Parser::Input XML; "Body¶GetCategoryProductsResponse" )]
# query number of products
Set Variable [$count; Value:MBS( "XML.NodeCount"; $oxml; "PRODUCT")]
# loop over products
Set Variable [$index; Value:0]
Loop
    # get a product
    Set Variable [$xml; Value:MBS( "XML.SubTree"; $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::" & $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

Example Databases


XML.NodeCount   -   XML.Parse

Feedback: Report problem or ask question.




Links
MBS Xojo PDF Plugins