1 Reply Latest reply on Apr 17, 2013 2:58 PM by nrgsoft

    Import XML Document - Help




      I'm using FileMaker Pro v12 and the BaseElements plugin to retrieve XML data which I'm storing in a variable at present. I then need to parse out the XML into individual records and set the field values along the way. I've only worked with simple XML structures before and I'm getting stuck on this one and also not sure what is the best approach.


      Here's a sample of the XML:


      <?xml version="1.0" encoding="utf-8"?>

      <checkRepliesResponse xmlns="http://www.w3.org/1999">

      <result returned="2" remaining="0">


      <reply format="message" uid="96541" receiptId="94211794">



      <content>message 1</content>


      <reply format="message" uid="8745" receiptId="94721243">



      <content>message 2</content>






      In this example there are 2 records that I need to create and for each record I need to get the value of these elments:








      I could parse the XML but that doesn't seem like the most efficient approach. Should I export it as an xml file somehow and then import it back in using XSLT?


      If anyone has any examples of how to write a XSLT that can get both attributes and elements at the same time that would be great.


      What would be the best practice to import the XML?




        • 1. Re: Import XML Document - Help

          Don't mess with export/import and XSLT. Using a simple custom function for parsing out the XML and another for getting text between.


          set variable $max=patterncount ( $xml ; "<reply" )

          if $max > 0

          set variable $ctr = 0


          set $ctr = $ctr + 1

          set variable $reply = GetTextBetween ( $xml ; "<reply" ; "</reply>" ; $ctr )

          set variable $uid= GetTextBetween ( $reply ; "uid=\"" ; "\"" ; 1 )

          set variable $receiptId= GetTextBetween ( $reply ; "receiptid=\"" ; "\"" ; 1 )

          set variable $origin= ExtractData ( $reply ; "origin" ; 1 )


          new record

          set field uid = $uid

          set field receiptid = $receiptid


          exit loop if $ctr = $max

          end loop

          end if