simplexml_load_file , attributes

운영자 | 기사입력 2010/10/24 [10:17]
>
필자의 다른기사 보기 인쇄하기 메일로 보내기 글자 크게 글자 작게
simplexml_load_file , attributes
 
운영자   기사입력  2010/10/24 [10:17]

<?
$o_url="http://xml.kr.overture.com//d/search/p/standard/xml/kr/spm2/mods/kk/?Keywords=dvd&Partner=krpartner_test&mkt=kr&outputCharEnc=euc-kr&maxCount=5&adultFilter=clean&bolding=true&serveUrl=http%3A%2F%2Fsearch.example.co.kr%2Fgosearch.cgi&affilData=ip%3D218.216.99.194%26xfip%3D211.201.123.32%26ua%3DMozilla%2f5.0+%28Windows%3b+U%3b+WinNT4.0%3b+ja?JP%3b+rv%3a1.0.2%29+Gecko%2f20030208+Netscape%2f7.02";
$xml = simplexml_load_file($o_url);
$t=0;
//print_r($xml);
echo $xml->ResultSet->Listing[title];

foreach ($xml->ResultSet->Listing as $value){
   $att=$value->attributes();
   $o_title=iconv("UTF-8","euckr",$att[title]);
 
   echo"$t $o_title :: $value->ClickUrl bbb<br>";

 //       $title=iconv("UTF-8","euckr",$value->title);
        //$value->code=iconv("UTF-8","euckr",$value->code);
//  echo"$value->id bbb<br>";
//    echo"$titla aaa $t<br>";
 
   $t++;
}
?>


 

<?php
$xml 
= <<<XML
<?xml version="1.0"?>
<Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet"
xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet">
<Table Foo="Bar" ss:ExpandedColumnCount="7">
</Table>
</Workbook>
XML;

$sxml = new SimpleXMLElement($xml);

/**
* Access attribute of default namespace
*/
var_dump((string) $sxml->Table[0]['Foo']);
// outputs: 'Bar'

/**
* Access attribute of non-default namespace
*/
var_dump((int) $sxml->Table[0]['ExpandedColumnCount']);
// outputs: 0

var_dump((int) $sxml->Table[0]->attributes('ss'TRUE)->ExpandedColumnCount);
// outputs: '7'
?>

 

=============================================

 $sc1=$xml->Metadata->Category->attributes()->{'code'};

 



 $creator = (String)$item->children('http://purl.org/dc/elements/1.1/')->creator;


cd:creator

트위터 트위터 페이스북 페이스북 카카오톡 카카오톡
기사입력: 2010/10/24 [10:17]  최종편집: ⓒ iwav