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
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];

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.