Results 1 to 1 of 1
-
09-22-2011, 06:50 AM #1
Freshman
- Join Date
- Feb 2011
- Posts
- 21
- Thanks
- 0
- Thanked 0 Times in 0 Posts
- Feedback Score
- 0
need help to parse simple XML to PHP
hi,
i'm trying to display this XML rss i receive using PHP , and its not working for me.
can anyone help displaying this?
this is the XML code:
Code:<RESPONSE> <EXPR>CAD</EXPR> <EXCH>USD</EXCH> <AMOUNT>1</AMOUNT> <NPRICES>1</NPRICES> <CONVERSION> <DATE>Thu, 10 May 2001 21:00:00 GMT</DATE> <ASK>1.5432</ASK> <BID>1.542</BID> </CONVERSION> <EXPR>CAD</EXPR> <EXCH>CAD</EXCH> <AMOUNT>1</AMOUNT> <NPRICES>1</NPRICES> <CONVERSION> <DATE>Fri, 11 May 2001 14:29:54 GMT</DATE> <ASK>1.0000</ASK> <BID>1.000</BID> </CONVERSION> </RESPONSE>
this is the code i wrote, the problem is that the EXPR EXCH... are at the sample level so running a foreach loop is a problem.
Code:<?php oandaObj = simplexml_load_file("XMLFILENNAME.xml"); $oandaArr = $oandaObj; ?> <ul> <?php foreach ($oandaArr as $key): ?> <li><?php echo $oandaArr->EXPR;?></li> <li><?php echo $oandaArr->EXCH;?></li> <li><?php echo $oandaArr->AMOUNT;?></li> <li><?php echo $oandaArr->NPRICES;?></li> <li><?php echo $oandaArr->CONVERSION->DATE;?></li> <li><?php echo $oandaArr->CONVERSION->BID;?></li> <li><?php echo $oandaArr->CONVERSION->ASK;?></li> <?php endforeach;?> </ul>
Similar Threads
-
Can I parse XML with PHP
By bgjyd834 in forum PHPReplies: 1Last Post: 09-09-2011, 10:12 PM -
Simple JavaScript RegEx to Parse Domain Name
By JavaScriptBank in forum JavaScript & AJAXReplies: 1Last Post: 08-25-2011, 06:58 AM -
Here is a simple SEO tip for you
By touchmenow1 in forum Search Engine OptimizationReplies: 11Last Post: 08-25-2011, 02:51 AM -
Date.parse not working
By Jack Nathan in forum JavaScript & AJAXReplies: 2Last Post: 04-18-2009, 11:24 AM -
Simple Web Design with Simple Rules
By manik in forum Graphics Design & Web DesignReplies: 3Last Post: 11-06-2008, 01:09 AM


Reply With Quote

