메뉴 건너뛰기

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로 부르면 된다.
박영식 (비회원)
    • 글자 크기

댓글 달기

박영식
2003.11.05 조회 17501
박영식
2008.07.23 조회 7786
lispro06
2016.11.01 조회 7142
suritam9
2013.08.23 조회 7125
이전 1 2 3 4 5 6 7 8 9 10... 14다음
첨부 (0)
위로