Displaying XML with PHP

shekki25shekki25 Midvale, UT
edited December 2010 in Internet & Media
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

Comments

  • lmorchardlmorchard {web,mad,computer} scientist Portland, OR Icrontian
    edited December 2010
    What version of PHP? Have you checked out SimpleXML?

    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....";
  • shekki25shekki25 Midvale, UT
    edited December 2010
    Thanks a ton man, that worked perfectly
    lmorchard wrote:
    What version of PHP? Have you checked out SimpleXML?

    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....";
Sign In or Register to comment.