Announcement

Collapse
No announcement yet.

Can Miva template code parse a XML string?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Can Miva template code parse a XML string?

    I want to parse this string:

    <?xml version="1.0" encoding="UTF-8"?>
    <response code="2" rate=".084" localrate=".019" loccode="0605"> <addressline code="0605" cez="" ptba="Clark PTBA" rta="N" period="Q32017" plus4="6627" zip="98661" state="WA" evenodd="E" houselow="620" househigh="620" street="PALO ALTO DR"/> <rate code="0605" localrate=".019" staterate=".065" name="VANCOUVER"/> </response>

    Thanks, Larry
    Larry
    Luce Kanun Web Design
    www.facebook.com/wajake41
    www.plus.google.com/116415026668025242914/posts?hl=en



    #2
    Yes there is a built in engine function:

    http://www.mivascript.com/item/mivas...xml_parse.html

    However for more complicated XML this won't be perfect. We have functions we use internally which first flatten the XML then we parse it to get better results.
    Brennan Heyde
    VP Product
    Miva, Inc.
    [email protected]
    https://www.miva.com

    Comment


      #3
      If mvt:call works the same as the original Miva Script MvCALL, it has quite a bit of parsing built in. If you're using mvt:call to retrieve this XML from a remote server, you can probably do all your parsing within the mvt:call loop.
      Kent Multer
      Magic Metal Productions
      http://TheMagicM.com
      * Web developer/designer
      * E-commerce and Miva
      * Author, The Official Miva Web Scripting Book -- available on-line:
      http://www.amazon.com/exec/obidos/IS...icmetalproducA

      Comment


        #4
        Hi Kent. Thanks for the info. Can you point me to any documentation about parsing in the mvt:call loop?
        Cheers, Larry
        Larry
        Luce Kanun Web Design
        www.facebook.com/wajake41
        www.plus.google.com/116415026668025242914/posts?hl=en


        Comment


          #5
          Trying to retrieve a XML response using mvt:call. This doesn't work:
          <mvt:assign name="g.addr" value = "g.basket:ship_addr1" />
          <mvt:assign name="g.city" value = "g.basket:ship_city" />
          <mvt:assign name="g.zip" value = "g.basket:ship_zip" />
          <mvt:assign name="g.output" value = "'XML'" />

          <mvt:call ACTION="'http://webgis.dor.wa.gov/webapi/addressrates.aspx'" METHOD="'XML'" TIMEOUT="'15'" FIELDS="'g.output,g.addr,g.city,g.zip'">
          <mvt:assign name="g.taxRate" value="s.callvalue" />
          </mvt:call>

          How should it be coded?
          Thanks, Larry
          Larry
          Luce Kanun Web Design
          www.facebook.com/wajake41
          www.plus.google.com/116415026668025242914/posts?hl=en


          Comment


            #6
            After looking at the mvt:call documentation I found that for my purposes using the toolkit callurl and the toolkit string functions worked best to parse the XML.
            Problem solved.
            Cheers, Larry
            Last edited by wajake41; 09-16-17, 07:55 PM.
            Larry
            Luce Kanun Web Design
            www.facebook.com/wajake41
            www.plus.google.com/116415026668025242914/posts?hl=en


            Comment

            Working...
            X