Displaying XML with PHP
shekki25
Midvale, UT
Hi, I'm in a little predicament and need some help. Hope someone here can help me.
I'm using an API for one of my manufacturers that spits out XML data. Here's a sample.
[HTML]<ResultSet totalResultsAvailable="94" title="ACHILLES">
<Model id="21528"><Title>FRB-104</Title><Years>09</Years></Model>[/HTML]
I can get the model to display just fine, but I'd like to also display the manufacturer on this page. In this case it's ACHILLES. For some reason they put the manufacturer as the title of the ResultSet. Is there any way to use PHP to display that on the page.
Any help would be greatly appreciated
I'm using an API for one of my manufacturers that spits out XML data. Here's a sample.
[HTML]<ResultSet totalResultsAvailable="94" title="ACHILLES">
<Model id="21528"><Title>FRB-104</Title><Years>09</Years></Model>[/HTML]
I can get the model to display just fine, but I'd like to also display the manufacturer on this page. In this case it's ACHILLES. For some reason they put the manufacturer as the title of the ResultSet. Is there any way to use PHP to display that on the page.
Any help would be greatly appreciated
0
Comments
http://php.net/manual/en/book.simplexml.php
You probably want something like:
$xml_str = get_xml_from_api();
<resultset....";
$doc = new SimpleXMLElement($xml_str);
$manufacturer = (string)$doc;</resultset....";