• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Reading XML file online using VBA - Getting this error

Here is my Macro

Code:
Option Explicit

Sub GetData()

Dim URL As String
Dim XMLData
Dim node As Object


URL = "...sample.xml"

Set XMLData = CreateObject("Microsoft.XMLDOM")
XMLData.Load URL

Debug.Print

For Each node In XMLData.SelectNodes("*//Date")
Debug.Print node.Text
Next

End Sub
 
XML file is very simple like this.

<Root>
<Calender>
<Date>2016-06-01</Date>
</Calender>
<Calender>
<Date>2016-06-02</Date>
</Calender>
 
Hi ,

The code given below works with the posted XML data.
Code:
Sub GetData()
    Dim URL As String
    Dim XMLData
    Dim node As Object

    URL = "C:\Users\AllUsers\Downloads\temp.xml"

    Set XMLData = CreateObject("Microsoft.XMLDOM")
    XMLData.Load URL

    For Each node In XMLData.SelectNodes("//Date")
        Debug.Print node.Text
    Next
End Sub

Code:
<?xml version="1.0" encoding="us-ascii"?>
<Root>
    <Calender>
        <Date>2016-06-01</Date>
    </Calender>
    <Calender>
        <Date>2016-06-02</Date>
    </Calender>
</Root>
Narayan
 
@NARAYANK991
Thank you.
1. Your code works fine on my PC, when xml file is stored locally. (i.e.desktop)

2. I am sorry I forgot to tell you that xml is stored online.
I am researching if it is to do with readystate...
 
Back
Top