메뉴 건너뛰기

infra

[PHP] XML parser의 이용

박영식2009.08.01 00:28조회 수 5409댓글 0

  • 1
    • 글자 크기
http://www.criticaldevelopment.net/xml/doc.php

<?php
 include "./XMLparse.php";                       // 클래스 파일 include
//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
();
?>

$parser->document->tagChildren
을 이용해 rout:car 등의 name을 갖는 속성값과 데이터 값을 얻어낼 수 있다.

$parser->document->tagChildren[2]->tagChildren[$j]->tagAttrs['name']
$parser->document->tagChildren[2]->tagChildren[$j]->tagChildren[0]->tagData

등으로 사용하면, 되고, var_dump 함수를 이용해 추적하면 쉽게 원하는 부분만 얻어낼 수 있다.

첨부된 파일은 확장자를 php로 바꿔서 사용하면 된다.
박영식 (비회원)
  • 1
    • 글자 크기
[PHP] 이름이 지정된 배열 처리하기 (by 박영식) [mysql] root 패스워드를 분실한 경우(응급조치) (by 박영식)

댓글 달기

박영식
2010.01.09 조회 3316
박영식
2009.08.01 조회 5409
박영식
2009.04.09 조회 3017
이전 1 ... 2 3 4 5 6 7 8 9 10 11다음
첨부 (1)
XMLparse.phps
12.0KB / Download 146
위로