0
C#을 사용하여 UWP의 서버에 저장된 XML 파일을 어떻게 읽습니까? 나는 XML 파일을 다운로드 시도하고이 코드를 사용하여 읽는 것 : 나는 응용 프로그램을 실행하면uwp에서 xml 파일을 읽는 방법
StorageFolder storageFolder = ApplicationData.Current.LocalFolder;
Uri address = new Uri("https://www.dropbox.com/s/lyf9lv03dogidb9/home.xml?dl=1");
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(address);
WebResponse response = await request.GetResponseAsync();
Stream stream = response.GetResponseStream();
StorageFile XMLfile = await storageFolder.CreateFileAsync("homemv.xml", CreationCollisionOption.ReplaceExisting);
await Windows.Storage.FileIO.WriteBytesAsync(XMLfile, ReadStream(stream));
//load data into flip view
StorageFile tempFile = await ApplicationData.Current.LocalFolder.GetFileAsync("homemv.xml");
String datas = await FileIO.ReadTextAsync(tempFile);
XDocument loadedData = XDocument.Load(datas);
var data = from query in loadedData.Descendants("mvinfo")
select new MVData
{
VideoTitle = (string)query.Element("title"),
VideoYear = (string)query.Element("year"),
VideoSource = (string)query.Element("link"),
ImageSource = (string)query.Element("imgSource")
};
YouTubeMV.ItemsSource = data;
, 그것은 열린 우리당 매개 변수가 파일 시스템 또는 절대 경로 여야한다는 오류를 보여줍니다. 다음과 같이 사용해 보았습니다.
Uri uri = new Uri("https://www.dropbox.com/s/lyf9lv03dogidb9/home.xml?dl=1");
XDocument document = XDocument.Load(uri);
또한 작동하지 않습니다.
합니다. 파일로 다운로드 할 필요가 없습니다. XDocument doc = XDocument.Load ("https://www.dropbox.com/s/lyf9lv03dogidb9/home.xml?dl=1"); – jdweng