0

I am using below code to get data from local file.

Source = "kur.xml"

Set kurlar = Server.CreateObject("msxml2.DOMDocument.6.0" )
kurlar.async = false
kurlar.resolveExternals = false
kurlar.setProperty "ServerHTTPRequest" ,true

kurlar.load(Source)

Set USD = kurlar.selectSingleNode("//Tarih_Date/Currency[@Kod = 'USD']")
USDS = USD.selectSingleNode("BanknoteSelling").text

Set EUR = kurlar.selectSingleNode("//Tarih_Date/Currency[@Kod = 'EUR']")
EURS = EUR.selectSingleNode("BanknoteSelling").text

But when I set xml source as external, I get "object required: 'USD'" error

Source = "https://www.tcmb.gov.tr/kurlar/today.xml"

By the way, both sources have exactly the same content.

Do I need to do something different when importing data from an external source?

Edit: This link doesn't work for me. My problem occurs when i use external source instead of local file. I solved my problem using ServerXMLHTTP with @John's suggestion.

zokanzi
  • 117
  • 3
  • 15
  • No, my problem occurs when i use external source instead of local file. – zokanzi Apr 11 '23 at 21:54
  • 1
    Does this answer your question? [How do I use MSXML2.ServerXMLHTTP to grab data from another site?](https://stackoverflow.com/q/11388714) – user692942 Apr 12 '23 at 08:31

1 Answers1

1

I've tried your code and it works fine from where I am, but here's another approach

<% 
Source = "https://www.tcmb.gov.tr/kurlar/today.xml"
Set http = Server.CreateObject("msxml2.ServerXMLHTTP.6.0")
http.Open "GET", Source, False
http.Send

Response.codepage = 65001
Response.charset = "utf-8"

Set kurlar = Server.CreateObject("msxml2.DOMDocument.6.0" )
kurlar.loadXML http.responseText


Set USD = kurlar.selectSingleNode("//Tarih_Date/Currency[@Kod = 'USD']")
USDS = USD.selectSingleNode("BanknoteSelling").text

Set EUR = kurlar.selectSingleNode("//Tarih_Date/Currency[@Kod = 'EUR']")
EURS = EUR.selectSingleNode("BanknoteSelling").text

Response.write usds & ", " & eurs
%>
John
  • 4,658
  • 2
  • 14
  • 23