Styling Yayın İçeriği XML Formatında döndü

0 Cevap php

Benim veritabanından bilgi çekerek ve ardından bir API karşı denetliyor bu kodu var. Ben bir tabloya dönüş bilgileri özelleştirmek için çalışıyorum. Ben ne istiyorsunuz göstermek için bir resim ekleyeceğiz. Ben her yerde aradım ve ben bu kodu nasıl bilmiyorum. Sadece bir tablo doldurmak için bilgi almak oluyor CSS endişe etmeyin.

<?php
        $key = "********************";
        $address = urlencode($CustomFields->field('jr_address',$listing,false,false));
        $city = $listing['Category']['title'];
        $zip = $CustomFields->field('jr_zipcode',$listing,false,false);
        $url = "http://api.greatschools.org/schools/nearby?key={$key}&address={$address}&city={$city}&state=MI&zip={$zip}&schoolType=public-charter&levelCode=elementary-schools&minimumSchools=50&radius=10&limit=5";
        $curl = curl_init();
        curl_setopt($curl, CURLOPT_URL, $url);
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
        $response = curl_exec($curl);      
        curl_close($curl); 
        print_r($response);
?><style type='text/css'>gsId{display:none;}name{color:#9BB055; font-size:18px;}type{display:none;}gradeRange{}enrollment{}gsRating{}city{display:none;}state{display:none;}district{}districtNCESId{display:none;}address{display:none;}phone{display:none; }fax{display:none;}ncesId{display:none;}lat{display:none;}lon{display:none;}</style>

Dönüş Kodu:

    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<schools>
<school>
<gsId>6350</gsId>
<name>Chinese Education Center</name>
<type>public</type>
<gradeRange>K-5</gradeRange>
<enrollment>63</enrollment>
<gsRating>3</gsRating>
<city>San Francisco</city>
<state>CA</state>
<district>San Francisco Unified School District</district>
<districtNCESId>0634410</districtNCESId>
<address>657 Merchant St., San Francisco, CA  94111</address>
<phone>(415) 291-7918</phone>
<fax>(415) 291-7965</fax>
<ncesId>063441005596</ncesId>
<lat>37.795</lat>
<lon>-122.4042</lon>
<overviewLink>http://www.greatschools.org/california/san-francisco/6350-Chinese-Education-Center/?s_cid=gsapi</overviewLink>
<ratingsLink>http://www.greatschools.org/school/rating.page?state=CA&amp;id=6350&amp;s_cid=gsapi</ratingsLink>
<reviewsLink>http://www.greatschools.org/school/parentReviews.page?state=CA&amp;id=6350&amp;s_cid=gsapi</reviewsLink>
</school>
<school>
<gsId>6389</gsId>
<name>Gordon J. Lau Elementary School</name>
<type>public</type>
<gradeRange>K-5</gradeRange>
<enrollment>667</enrollment>
<gsRating>7</gsRating>
<city>San Francisco</city>
<state>CA</state>
<district>San Francisco Unified School District</district>
<districtNCESId>0634410</districtNCESId>
<address>950 Clay St., San Francisco, CA  94108</address>
<phone>(415) 291-7921</phone>
<fax>(415) 291-7952</fax>
<website>http://www.gjles.org/</website>
<ncesId>063441005599</ncesId>
<lat>37.794</lat>
<lon>-122.4086</lon>
<overviewLink>http://www.greatschools.org/california/san-francisco/6389-Gordon-J.-Lau-Elementary-School/?s_cid=gsapi</overviewLink>
<ratingsLink>http://www.greatschools.org/school/rating.page?state=CA&amp;id=6389&amp;s_cid=gsapi</ratingsLink>
<reviewsLink>http://www.greatschools.org/school/parentReviews.page?state=CA&amp;id=6389&amp;s_cid=gsapi</reviewsLink>
</school>
</schools>

I don't know how to write the script to make it look like this: Link to image: link text


Yani yeni bir dosya gibi görünüyor?

<?php
    $key = "xxxxxxxxxxxxxxxxxxxxxxxx";
    $address = urlencode($CustomFields->field('jr_address',$listing,false,false));
    $city = $listing['Category']['title'];
    $zip = $CustomFields->field('jr_zipcode',$listing,false,false);
    $url = "http://api.greatschools.org/schools/nearby?key={$key}&address={$address}&city={$city}&state=MI&zip={$zip}&schoolType=public-charter&levelCode=elementary-schools&minimumSchools=50&radius=10&limit=5";
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL, $url);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
    $response = curl_exec($curl);      
    curl_close($curl);
    echo (xml2html($response, "/xslt/schools.xsl");

>

Ben yankı satırında bir hata alıyorum.

Nereye gidiyor bu?

<?php
function xml2html($xmldata, $xslPath)
{
    /* $xmldata -> your XML */
    /* $xsl -> XSLT file */

    $arguments = array('/_xml' => $xmldata);
    $xsltproc = xslt_create();
    xslt_set_encoding($xsltproc, 'ISO-8859-1');
    $html =
        xslt_process($xsltproc, 'arg:/_xml', $xslPath, NULL, $arguments);

    if (empty($html)) {
       die('XSLT processing error: '. xslt_error($xsltproc));
    }
    xslt_free($xsltproc);
    return $html;
}
?>

0 Cevap