메뉴 건너뛰기

app

[PHP] XML 파서

박영식2008.07.24 15:09조회 수 4795댓글 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] 나라기록검색서비스 OpenApi Library for PHP (by 박영식) [PHP] TM, WGS 좌표변환 (by 박영식)

댓글 달기

박영식
2010.09.09 조회 4907
박영식
2010.05.25 조회 4259
박영식
2010.01.14 조회 5094
박영식
2009.09.21 조회 4274
박영식
2008.08.18 조회 6198
박영식
2008.08.17 조회 4385
박영식
2008.07.24 조회 4795
박영식
2008.07.23 조회 8151
박영식
2008.07.22 조회 3472
박영식
2008.04.11 조회 2322
박영식
2008.01.20 조회 2170
박영식
2007.12.23 조회 3339
첨부 (0)
위로