XML Download Read
来源:互联网 发布:上眼皮下垂恢复知乎 编辑:程序博客网 时间:2024/06/06 14:28
public static void downLoadXMLFileAndSeperateFileToSourceWebFolder()
{
string link = "http://www.heb.com/sitemap/recipeSitemap.xml";
var web = new WebClient();
web.Headers.Add("user-agent", "Only a test!");
var path = "siteMap.xml";
try
{
web.DownloadFile(link, path);
XmlDocument xmldoc = new XmlDocument();
xmldoc.Load(path);
var nodes = xmldoc["urlset"].ChildNodes;
int i = 0;
foreach (var node in nodes)
{
var nodeChild = node as XmlNode;
if (nodeChild != null && nodeChild["loc"] != null)
{
var url = nodeChild["loc"].InnerText;
var webNode = new WebClient();
webNode.Headers.Add("user-agent", "Only a test!");
webNode.DownloadFile(url, "SourceNodes/" + i + ".xml");
i++;
}
}
}
catch (Exception ex)
{
Console.WriteLine(ex);
}
}
{
string link = "http://www.heb.com/sitemap/recipeSitemap.xml";
var web = new WebClient();
web.Headers.Add("user-agent", "Only a test!");
var path = "siteMap.xml";
try
{
web.DownloadFile(link, path);
XmlDocument xmldoc = new XmlDocument();
xmldoc.Load(path);
var nodes = xmldoc["urlset"].ChildNodes;
int i = 0;
foreach (var node in nodes)
{
var nodeChild = node as XmlNode;
if (nodeChild != null && nodeChild["loc"] != null)
{
var url = nodeChild["loc"].InnerText;
var webNode = new WebClient();
webNode.Headers.Add("user-agent", "Only a test!");
webNode.DownloadFile(url, "SourceNodes/" + i + ".xml");
i++;
}
}
}
catch (Exception ex)
{
Console.WriteLine(ex);
}
}
0 0
- XML Download Read
- Download interrupted: Read timed out
- XML Read
- read xml
- FtpClient read write create upload download
- javaScript read of xml
- Read .XML file
- Read and Write XML
- vbs read xml
- READ Write xml
- xml read check
- read XML - SAX parser
- read XML-DOM parser
- C# read XML file
- Read XML with namespace
- Java XML Read
- test code read xml
- javascript read local xml
- Android JPush(极光推送)的使用教程
- foreach的参数需要注意
- android 开机自启动脚本
- Swift:表格视图单元格单选(二)
- C++中引用(&)用法和实例解析
- XML Download Read
- ng-repeat指令实现循环输出 ng-click 动态触发
- 架构是为业务服务的,一切不以业务为指标的架构都是耍流氓
- 测试代码功能
- redis 定义
- 系统工程的十大建模建议: #4 通过设计模式来重用经过验证的解决方案
- UML类图几种关系的总结
- JAVA关键字NULL小谈
- Windows提权的几种姿势