SimpleXMLElement を使用して XML ファイルを解析しています (XBRL は XML ベースです)。
$url = 'http://sec.gov/Archives/edgar/data/104169/000119312511158587/wmt-20110430.xml';
$sec_file = file_get_contents($url) or die('Could not access file: $url');
$xml = new SimpleXMLElement($sec_file);
foreach($xml->{'us-gaap:InterestExpenseDebt'} as $item) {
print_r($item);
}
ただし、 tag の値を取得できませんus-gaap:InterestExpenseDebt
。
XML では次のように定義されています。
<us-gaap:InterestExpenseDebt contextRef="Duration_2_1_2010_To_4_30_2010" unitRef="Unit12" decimals="-6">455000000</us-gaap:InterestExpenseDebt>
<us-gaap:InterestExpenseDebt contextRef="Duration_2_1_2011_To_4_30_2011" unitRef="Unit12" decimals="-6">491000000</us-gaap:InterestExpenseDebt>
この XML ファイルの名前空間は
<xbrli:xbrl xmlns:cvs="http://www.info.cvscaremark.com/20110630" xmlns:link="http://www.xbrl.org/2003/linkbase" xmlns:us-gaap="http://fasb.org/us-gaap/2011-01-31" xmlns:xbrldi="http://xbrl.org/2006/xbrldi" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xbrli="http://www.xbrl.org/2003/instance" xmlns:iso4217="http://www.xbrl.org/2003/iso4217" xmlns:dei="http://xbrl.sec.gov/dei/2011-01-31" xmlns:xlink="http://www.w3.org/1999/xlink">
これを追加しましたが、まだ機能しません:
$xml->registerXPathNamespace('us-gaap', "http://fasb.org/us-gaap/2011-01-31");
助言がありますか?
ありがとう!