▼ 2008/01/08(火) SimpleXMLElementと配列
参考
http://oshiete1.goo.ne.jp/qa1972271.html
http://php.plus-server.net/ref.simplexml.html
http://oshiete1.goo.ne.jp/qa1972271.html
http://php.plus-server.net/ref.simplexml.html
Example#6 要素および属性をテキストと比較する
要素または属性を文字列と比較する、もしくは、文字列を引数とする関数に 渡すには、(string) により文字列にキャストする 必要があります。さもないと、PHPはこの要素をオブジェクトとして扱います。
<?php
include 'example.php';
$xml = new SimpleXMLElement($xmlstr);
if ((string) $xml->movie->title == 'PHP: Behind the Parser') {
print 'My favorite movie.';
}
htmlentities((string) $xml->movie->title);
?>
▼ コメント(0件)
- TB-URL http://www.cpa-lab.com/tech/02/tb/