我正在尝试DownloadData
. WebClient
我当前的问题是,我无法弄清楚如何将生成的ASCII
结果(<
到<
、、到\n
)转换为从该页面产生的结果。>
>
Encoding.ASCII.GetString(myDataBuffer);
(来源:iforce.co.nz)
/// <summary>
/// Curl data from the PMID
/// </summary>
private void ClientPMID(int pmid)
{
//generate the URL for the client
StringBuilder pmid_url_string = new StringBuilder();
pmid_url_string.Append("http://www.ncbi.nlm.nih.gov/pubmed/").Append(pmid.ToString()).Append("?report=xml");
Uri PMIDUri = new Uri(pmid_url_string.ToString());
//declare and initialize the client
WebClient client = new WebClient();
// Download the Web resource and save it into a data buffer.
byte[] myDataBuffer = client.DownloadData(PMIDUri);
this.DownloadCompleted(myDataBuffer);
}
/// <summary>
/// Crawl over the binary from myDataBuffer
/// </summary>
/// <param name="myDataBuffer">Binary Buffer</param>
private void DownloadCompleted(byte[] myDataBuffer)
{
string download = Encoding.ASCII.GetString(myDataBuffer);
PMIDCrawler pmc = new PMIDCrawler(download, "/pre/PubmedArticle/MedlineCitation/Article");
//iterate over each node in the file
foreach (XmlNode xmlNode in pmc.crawl)
{
string AbstractTitle = xmlNode["ArticleTitle"].InnerText;
string AbstractText = xmlNode["Abstract"]["AbstractText"].InnerText;
}
}
PMIDCrawler 的代码可在我关于DownloadStringCompletedEventHandler
. 虽然从. string html = HttpUtility.HtmlDecode(nHtml);
_ _ _xml
Encoding.ASCII.GetString