openapi 에 xml 과 xsl 적용하기 여러분들은 어떤 식으로 하나요?
저는 이렇게 해 보았습니다.http://sebul.sarang.net/q2a/?qa=33
<?php $xml=new DOMDocument(); $xml->load('http://openapi.seoul.go.kr:8088/4d4141507373656233354c61444958/xml/RealtimeCityAir/1/25/'); $xsl = new DOMDocument(); $xsl->load('a.xsl'); // $proc = new XSLTProcessor; $proc->importStyleSheet($xsl); // echo $proc->transformToXML($xml); ?>
a.xsl
<?xml version="1.0" encoding="utf-8"?> <xsl:transform version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="/"> <html> <meta charset="utf-8" /> <body> <h1><xsl:value-of select="RealtimeCityAir/row/MSRDT"/></h1> <table > <tr> <th>구</th><th>미세먼지 농도</th> </tr> <xsl:for-each select="RealtimeCityAir/row"> <tr> <td><xsl:value-of select="MSRSTE_NM"/></td> <td><xsl:value-of select="PM10"/> µ/m<sup>3</sup></td> </tr> </xsl:for-each > </table> </body> </html> </xsl:template> </xsl:transform>
세벌 https://sebuls.blogspot.kr/
텍스트 포맷에 대한 자세한 정보
<code>
<blockcode>
<apache>
<applescript>
<autoconf>
<awk>
<bash>
<c>
<cpp>
<css>
<diff>
<drupal5>
<drupal6>
<gdb>
<html>
<html5>
<java>
<javascript>
<ldif>
<lua>
<make>
<mysql>
<perl>
<perl6>
<php>
<pgsql>
<proftpd>
<python>
<reg>
<spec>
<ruby>
<foo>
[foo]
예제 코드
a.xsl
세벌 https://sebuls.blogspot.kr/
댓글 달기