메뉴 건너뛰기

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
    • 글자 크기
[mysql] load_file 취약점 (by 박영식) [MSSQL] db정보, 차집합, 문자 타입 변환 (by 박영식)

댓글 달기

박영식
2011.04.29 조회 6053
박영식
2009.08.01 조회 5409
lispro06
2016.03.30 조회 4588
첨부 (1)
XMLparse.phps
12.0KB / Download 146
위로