1

この (" http://www.ploscompbiol.org/article/info%3Adoi%2F10.1371%2Fjournal.pcbi.1002244 ") ページのドキュメントを xml ファイルとしてダウンロードしたいと思います。webclient.downloadfile() を試しましたが、エラーが発生しました。誰もがC#を使用してそれを行う方法を提案できますか.

ありがとう。

4

1 に答える 1

3

次のようなものを使用できます: (私が使用している URL に注意してください...)

public static string DownloadString(string address) 
{
    string text;
    using (var client = new WebClient()) 
    {
        text = client.DownloadString(address);
    }
    return text;
}

private static void Main(string[] args) 
{    
    var xml = DownloadString(@"http://www.ploscompbiol.org/article/fetchObjectAttachment.action?uri=info%3Adoi%2F10.1371%2Fjournal.pcbi.1002244&representation=XML");            
    File.WriteAllText("blah.xml", xml);
}
于 2013-06-10T23:28:44.687 に答える