Searching XML using XBRL Schema

mchac

Well-known Member
Joined
Apr 15, 2013
Messages
531
I'm trying to pull specific data from XML files using XBRL structure. An example XML file is here
Index of /Archives/edgar/data/104169/000010416912000018
file: 0000104169-12-000018-xbrl.zip
(it's a Walmart financial filing from 31oct2012)

My understanding is that once that file is downloaded it's possible to pull specific bits of data using VB. I know very little about XML parsing and search but two sources I've found suggest a simple sub similar to the following. However I'm getting Run-time error 91 and I can't undrstand why the object variable isn't set. Does anyone see an obvious error in this?

Code:
Sub GetXBRLData()
    Dim LOADFILE As String
    LOADFILE = "'path to file'\wmt-20121031.xml"   'xml instance document
    
    Dim CONCEPT As String
    CONCEPT = "us-gaap:AccountsPayableCurrent"
    
    Dim CONTEXT As String
    CONTEXT = "I2013Q3"
    
    Dim oDocument As MSXML2.DOMDocument30
    Set oDocument = New MSXML2.DOMDocument30
    
    oDocument.async = False
    oDocument.validateOnParse = False
    oDocument.Load (LOADFILE)
    
    Dim FACTVALUE As String
    FACTVALUE = oDocument.SelectSingleNode("/" & CONCEPT & "[@contextref='" & CONTEXT & "']").Text
    MsgBox FACTVALUE
    
    Set oDocument = Nothing
End Sub
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
In case anyone is interested in getting this kind of data, my error was in the FACTVALUE line. Needs "//" not "/" and "contextRef" not "contextref".

Code:
FACTVALUE = oDocument.SelectSingleNode("//" & CONCEPT & "[@contextRef='" & CONTEXT & "']").Text
 
Upvote 0

Forum statistics

Threads
1,214,570
Messages
6,120,296
Members
448,954
Latest member
EmmeEnne1979

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top