Parse XML

Version 2

     

    Custom Function

     

    Compatibility
    Creator
    Mac OS X, Windows
    andy knasinski
    FMP 8.5, 9, 10, 11
    nrg software, llc.
    Web: Yes
    File Type: None
    Server: Yes
    FileSize: 0 kilobytes
    http://www.nrgsoft.com

    Description

    Allows for parsing of simple XML documents without the need to create stylesheets.

     


    Code

    // ExtractData ( XML ; Attribute ; Instance )

     

    Let ( [

    XML_Length = Length ( XML ) ;

    Attribute_Length = Length ( Attribute ) ;

    Get_Instance = If ( IsEmpty ( Instance ) ; 1 ; Instance )

    ];

    Case(

    IsEmpty ( XML ) or IsEmpty ( attribute ) or PatternCount ( xml ; "<" & attribute & ">" ) = 0 ; "" ;

    Middle ( XML ; Position ( XML ; "<" & attribute & ">" ; 1 ; Get_Instance ) + attribute_length + 2 ;

    xml_length - ( xml_length - Position ( XML ; "" ; 1 ; Get_Instance ) ) - ( Position ( XML ; "<" & attribute & ">" ; 1 ; Get_Instance ) + Attribute_Length + 2 ) )

    ) )

     

    Sample Input

    Sample Output

    ExtractData ( "

    123

    456

    789

    " ; "InvNum" ; 2 )


    456

    Developer's Notes

    Extract specific data out of XML formatted text without using FileMaker's built-in XML functionality.

     


    FileMaker Inc. provides this content on an “As Is” basis, without any warranty, and subject to the terms of the FileMaker Technical Network Agreement. FileMaker makes no representations and is not liable for any content or related information. You may use the content as part of your own solutions and for your customers, but you may not otherwise publicly distribute any content that you did not submit. ©2009-2011 FileMaker, Inc. All Rights Reserved. FileMaker is a trademark of FileMaker, Inc. registered in the U.S. and other countries.