Question

I am using the code below to bind data from a XML file in my PC. It works fine when using a local PC filePath, but when I change the location of the XML filePath to an URL which is listed below. it simply doesn't work. I made this xml file public in my onedrive but still doen´t work. Do I need to download the file and then readXML?

Many Thanks,

Imports System
Imports System.IO
Imports System.Net
Imports System.Xml

Public Class NasgoLive

Private Sub RefreshButton_Click(sender As Object, e As EventArgs) Handles RefreshButton.Click, RefreshButton.Click

    MessageBox.Show("Done")

    Me.BackColor = Color.FloralWhite

    Dim filePath As String = "Complete path where you saved the XML"
    AuthorsDataSet.ReadXml("https://onedrive.live.com/?  cid=42FE4354E1EDA2AE&id=42FE4354E1EDA2AE%21674")

    alliancehorizonvalue.DataSource = AuthorsDataSet
    alliancehorizonvalue.DataMember = "alliancehorizon"
    arcticovalue.DataSource = AuthorsDataSet
    arcticovalue.DataMember = "arctico"
Was it helpful?

Solution

You need to download the file first. DataSet.ReadXml supports just a file name, not url.

You could download the file with a WebClient (not tested):

byte[] data;
using (WebClient client = new WebClient()) {
    data = client.DownloadData("https://onedrive.live.com/?cid=42FE4354E1EDA2AE&id=42FE4354E1EDA2AE!674");
}
File.WriteAllBytes(@"c:\myfile.xml", data);

EDIT: For downloading you need to use OneDrive API

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top