1

I have a XML From Quickbase that I am trying to get foreach into smarty. The xml looks like below. is a child of , and there are multiple records. In Smarty I have a foreach bracket with the url of the xml. I Can't seem to get anyting to show up. there are no compile errors. Any Help Appreciated.

MyXML:

<qdbapi>
    <action>API_DoQuery</action>
    <errcode>0</errcode>
    <errtext>No error</errtext>
    <dbinfo>
        <name>Part Details</name>
        <desc/>
    </dbinfo>
    <variables></variables>
    <chdbids></chdbids>
    <record>
        <related_bid>48</related_bid>
        <part_note>This is a note 1</part_note>
        <record_id_>24</record_id_>
        <update_id>1417012758913</update_id>
    </record>
    <record>
        <related_bid>48</related_bid>
        <part_note>This is a note 2</part_note>
        <record_id_>24</record_id_>
        <update_id>1417012758913</update_id>
    </record>
</qdbapi>

my Smarty:

 {$xml = simplexml_load_file('myquickbasexmlurl')}
     {foreach $xml->qdbapi->record as $detail}
         {$detail->record_id_} - {$detail->part_note}
     {/foreach}

Thank You

Naruto
  • 1,210
  • 3
  • 25
  • 28
T Varcor
  • 375
  • 1
  • 2
  • 11

1 Answers1

0

It looks like you are trying to do php functions within smarty so you need to put it in php tags

{php}
    $xml = simplexml_load_file('myquickbasexmlurl')
    foreach ($xml->qdbapi->record as $detail)
    {
        echo $detail->record_id . "-" . $detail->part_note;
    }
{/php}

This is not best practice according to smarty, but sometimes you may need to use it. Otherwise you need to create a smarty variable with the xml then process the rest with smarty.

Demodave
  • 6,242
  • 6
  • 43
  • 58