메뉴 건너뛰기

app

[PHP] XML 파서

박영식2008.07.24 15:09조회 수 4405댓글 0

    • 글자 크기
그동안 야매(?)로 XML을 파싱하고 있었는데, 드디어, 좋은 CLASS를 구했다.

클래스를 아래에서 다운로드 받은 뒤, 인클루드 시키고,

http://www.criticaldevelopment.net/xml/doc.php


<?php
//Get the XML document loaded into a variable
$xml = file_get_contents('example.xml');
//Set up the parser object
$parser = new XMLParser($xml);

//Work the magic...
$parser->Parse();

echo " : ".$parser->document->channel[0]->item[$i]->title[0]->tagName." : ".$parser->document->channel[0]->item[$i]->title[0]->tagData."";

?>
하면 된다.

예제에서는 file_get_contents()로 XML을 요청했는데, 보안문제로 안 될 경우에는 HttpRequest로 부르면 된다.
박영식 (비회원)
    • 글자 크기
[PHP] TM, WGS 좌표변환 (by 박영식) [PHP] 나라기록검색서비스 OpenApi Library for PHP (by 박영식)

댓글 달기

이전 1 2 3 4 5 6 7 8 9 10... 14다음
첨부 (0)
위로