Parse XML from External API

Options
Anyway to easily parse XML coming from an External API.  I can't access the elements in it easily, so I want to convert it into an array that I can then return to Bubble.

So far - I've had limited success with regex expressions; and am thinking of just looping thru the string with substring & indexes.  

Comments

  • Michael Udinski
    Michael Udinski Administrator

    ADMIN

    Options
     have you tried out the xml_decode filter yet? This might help get the data into a format that is easier to manipulate
  • Neil Harrington
    Options
    There's an xml_decode filter?  Sheesh.  I didn't find that; will look tomorrow morning.  Likely way better than my approach.  
  • Neil Harrington
    Options
    Couldn't wait.   Tried the xml_decode filter -- it only pulled the first element rather than an array of them.

    This is the xml:
    The xml_decode only got the 1st vehicle, and the 1st item of that vehicle.

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

       
           
               
               
               
               
           
           
               
               
               
               
           
           
               
               
               
               
           
       



    Returned Result:
    {
    VINquery: {
    @attributes: {
    Version: 1.0.0},
    value: {
    VIN: {
    @attributes: {
    Number: 2T1BURHE3HC952686,
    Status: SUCCESS},
    value: {
    Vehicle: {
    @attributes: {
    Model_Year: 2017,
    Make: Toyota,
    Model: Corolla,
    Trim_Level: L CVT},
    value: {
    Item: {
    @attributes: {
    Key: Model_Year,
    Value: 2017,
    Unit: },
    value: }}}}}}}}
  • Michael Udinski
    Michael Udinski Administrator

    ADMIN

    Options
     the xml_decode filter has been fixed to work on the entire array of the response
  • Neil Harrington
    Options
    Excellent - I've implemented that instead of my wacko string manipulation.  Much appreciated.
  • AgIQ
    AgIQ Member
    Options

    @Neil Harrington , would you mind showing how / where you added the xml_decoder filter? Thx!

  • 5h8yn8
    5h8yn8 Member
    Options

    What should the input be for XML? Is it text or JSON? I'm continuously running into parsing errors. I'd prefer it to be a url, but that didn't seem to work either. Thanks in advanced!