Currently I have the following XML document:
<Programs>
<Program>
<ProductTypeNam e>30 Yr Fixed</ProductTypeName >
<Rate>6.250</Rate>
<APR>6.274</APR>
<InvestorName>H elos</InvestorName>
<Payment>2832.2 98</Payment>
</Program>
<Program>
<ProductTypeNam e>30 Yr Fixed</ProductTypeName >
<Rate>9.250</Rate>
<APR>9.293</APR>
<InvestorName>A valon</InvestorName>
<Payment>3784.3 06</Payment>
</Program>
<Program>
<ProductTypeNam e>5/1 Arm</ProductTypeName >
<Rate>6.375</Rate>
<APR>6.399</APR>
<InvestorName>C arl1</InvestorName>
<Payment>2869.8 02</Payment>
</Program>
</Programs>
I load it up in a domdocument and iterate through it with the following:
$returns = array();
for($i = 0; $i < $xmlproducttype->length; $i++)
{
$returns[$i]['ProductTypeNam e'] =
$xmlproducttype->item($i)->nodeValue;
$returns[$i]['InvestorName'] =
$xmlinvestornam e->item($i)->nodeValue;
$returns[$i]['Rate'] = $xmlrate->item($i)->nodeValue;
$returns[$i]['APR'] = $xmlapr->item($i)->nodeValue;
$returns[$i]['Payment'] = $xmlpayment->item($i)->nodeValue;
}
Giving me the following style array:
$returns['0']['ProductTypeNam e']
What I need to figure out is how to iterate through this XML document to
make an array where the unique ProductTypeName , which can be repeated many
times, is the key name and the values are the other elements in the xml
document. I am looking to get something like the following:
$records=array(
array('30 year fixed' =>
array('Investor Name' =Carl1, 'Rate'=>6.0, ...)
array('Investor Name' =Avalon, 'Rate'=>6.0, ...)
print_r($record s['30 year fixed']['InvestorName']) = Avalon
--
Posted via a free Usenet account from http://www.teranews.com
<Programs>
<Program>
<ProductTypeNam e>30 Yr Fixed</ProductTypeName >
<Rate>6.250</Rate>
<APR>6.274</APR>
<InvestorName>H elos</InvestorName>
<Payment>2832.2 98</Payment>
</Program>
<Program>
<ProductTypeNam e>30 Yr Fixed</ProductTypeName >
<Rate>9.250</Rate>
<APR>9.293</APR>
<InvestorName>A valon</InvestorName>
<Payment>3784.3 06</Payment>
</Program>
<Program>
<ProductTypeNam e>5/1 Arm</ProductTypeName >
<Rate>6.375</Rate>
<APR>6.399</APR>
<InvestorName>C arl1</InvestorName>
<Payment>2869.8 02</Payment>
</Program>
</Programs>
I load it up in a domdocument and iterate through it with the following:
$returns = array();
for($i = 0; $i < $xmlproducttype->length; $i++)
{
$returns[$i]['ProductTypeNam e'] =
$xmlproducttype->item($i)->nodeValue;
$returns[$i]['InvestorName'] =
$xmlinvestornam e->item($i)->nodeValue;
$returns[$i]['Rate'] = $xmlrate->item($i)->nodeValue;
$returns[$i]['APR'] = $xmlapr->item($i)->nodeValue;
$returns[$i]['Payment'] = $xmlpayment->item($i)->nodeValue;
}
Giving me the following style array:
$returns['0']['ProductTypeNam e']
What I need to figure out is how to iterate through this XML document to
make an array where the unique ProductTypeName , which can be repeated many
times, is the key name and the values are the other elements in the xml
document. I am looking to get something like the following:
$records=array(
array('30 year fixed' =>
array('Investor Name' =Carl1, 'Rate'=>6.0, ...)
array('Investor Name' =Avalon, 'Rate'=>6.0, ...)
print_r($record s['30 year fixed']['InvestorName']) = Avalon
--
Posted via a free Usenet account from http://www.teranews.com
Comment