【发布时间】:2011-08-19 20:08:07
【问题描述】:
我正在使用 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);
}
但是,我无法获取标签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");
有什么建议吗?
谢谢!
【问题讨论】: