Jump to content

Reading XML data from EDGAR with PHP


brady123

Recommended Posts

I'm trying to use PHP to read data from EDGAR, the SEC's website for company filings. Filings are in XBRL, a standard for XML. I'm having trouble pulling data using PHP.

 

Here is a link to the data: http://www.sec.gov/Archives/edgar/da...g-20101231.xml

 

Using PHP, I'm trying to get the data from, for example, the following tag:

 

<us-gaap:Assets contextRef="eol_PE633170--1010-K0013_STD_0_20091231_0" unitRef="iso4217_USD" decimals="-6">40497000000</us-gaap:Assets>

 

I've been unsuccessful thus far in getting this data - do you have any suggestions on how to do that?

 

Thank you!

Link to comment
https://forums.phpfreaks.com/topic/248771-reading-xml-data-from-edgar-with-php/
Share on other sites

I think you should try harder. Also your request is very unclear about what it is you want.

 

Anyhow, to extract the Asset node (there are two), you do like this, the number in the bracket denotes which of them you want (in order of appearance in the file, starting from zero):

 

$xml = simplexml_load_file('goog-20101231.xml');
$namespaces = $xml->getNamespaces(true);

echo $xml->children($namespaces['us-gaap'])->Assets[0];

You're right - I should have been more explicit with what I was asking and given the code I had already tried. I guess I was just frustrated I couldn't get it to work I just posted quickly :P

 

Anyways, thank you SO much for your help! The namespace part was where I was lacking. Thanks again. Cheers!

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.