------ items.xml -------- 파일
<?xml version="1.0" encoding="UTF-8"?>
<ewdid>
<item>
<code>0001</code>
<price>1000</price>
<name0>헤이즐넛카페모카</name0>
<ctg>HOT커피류</ctg>
</item>
<item>
<code>0002</code>
<price>2000</price>
<name0>화이트초코카페모카</name0>
<ctg>HOT커피류</ctg>
</item>
<item>
<code>0003</code>
<price>1000</price>
<name0>카페라떼</name0>
<ctg>HOT커피류</ctg>
</item>
</ewdid>
------ xmlparser.html --------
<?
// displays all the file nodes
if(!$xml=simplexml_load_file('items.xml')){
trigger_error('Error reading XML file',E_USER_ERROR);
}
echo 'Displaying contents of XML file...<br />';
foreach($xml as $item){
echo 'CODE: '.$item->code.' PRICE: '.$item->price.'
CTG: '.iconv("UTF-8","EUC-KR", $item->ctg)
.'<br />';
}
?>