Using MSXML to extract data from a Node

mchac

Well-known Member
Joined
Apr 15, 2013
Messages
531
First, I'm very inexperienced in parsing XML and I'm using someone else's code (who isn't available for help) at the moment to accomplish a task while I learn how the code works.

For most of my task the code works fine but in a few instances it doesn't and I can't identify why.

I'm loading a document using the following for one particular case.

Code:
Private Sub LoadInstanceDocIntoMemory()


        Set oInstance = New MSXML2.DOMDocument60
        oInstance.async = False
        oInstance.validateOnParse = False
        oInstance.Load "http://www.sec.gov/Archives/edgar/data/1111335/000111133513000004/vc-20121231.xml"
        
        If oInstance.parseError.ErrorCode <> 0 Then
            PARSE_ERROR_CODE = oInstance.parseError.ErrorCode
        End If




End Sub

Then I'm using this to extract info from the xml:
Code:
    Set oNodelist = oInstance.SelectNodes("//us-gaap:SalesRevenueGoodsNet[@contextRef='D2012Q4YTD']")

    If oNodelist.Length > 0 Then
        
        GetBalShtAndIncStmtData = oInstance.SelectSingleNode("//us-gaap:SalesRevenueGoodsNet[@contextRef='D2012Q4YTD']").Text

    End If

As I step through the code I see that oNodelist.Length = 0 so the GetBalShtAndIncStmtData sub is not executed and that's ultimately why I'm not getting data.

But if I open the XML page in a browser and search for the number that the code above is supposed to find (6857000000), I see that it is there (in two places, the second instance is the one that should satisfy the code above).

Given my inexperience with XML I've been unable to troubleshoot this so far. Any ideas or references are greatly appreciated.
 

Some videos you may like

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.

mchac

Well-known Member
Joined
Apr 15, 2013
Messages
531
Ok, thanks. I'll have a look.
I just can't understand why in my example there's a problem with the specification. The data is there.
 

Watch MrExcel Video

Forum statistics

Threads
1,122,576
Messages
5,596,965
Members
414,114
Latest member
Lost_User21

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
Top