Показать сообщение отдельно
Старый 03.01.2009, 18:36   #1  
Blog bot is offline
Blog bot
Участник
 
25,643 / 848 (80) +++++++
Регистрация: 28.10.2006
axaptapedia: Load Web Documents
Источник: http://www.axaptapedia.com/Load_Web_Documents
==============

Summary:

Loading web documents is easy using Microsoft .NET Framework in Dynamics AX. All necessary classes are implemented in System.IO Namespace and ready to use in Dynamics AX. For example reading the HTML document from Axaptapedia.com can be done in this way:


System.Net.WebRequest request = System.Net.WebRequest::Create("http://www.axaptapedia.com");
System.Net.WebResponse response;
System.IO.StreamReader reader;
System.IO.Stream stream;
System.String line;
;

response = request.GetResponse();
stream = response.GetResponseStream();
reader = new System.IO.StreamReader(stream);
line = reader.ReadLine();
while(line != null)
{
info(line);
line = reader.ReadLine();
}

reader.Close();


==Loading XML document==
While XML is the default industry standard for data exchange, it is simple to load published XML documents. News Feeds are published as XML documents that are interpreted by a browser or mail client like outlook to provide a convenient user interface. To handle XML documents add the System.Xml namespace at the AOT.


// MSDN RSS feed
System.Net.WebRequest request = System.Net.WebRequest::Create("http://www.microsoft.com/feeds/msdn/en-us/rss.xml");
System.Net.WebResponse response;
System.IO.StreamReader reader;
System.IO.Stream stream;

System.String xmlFeed;
System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
System.Xml.XmlNodeList nodeList;
System.Collections.IEnumerator titleEnum;
System.Xml.XmlNode title,value;
;

// Load
response = request.GetResponse();
stream = response.GetResponseStream();
reader = new System.IO.StreamReader(stream);
xmlFeed = reader.ReadToEnd();
reader.Close();

// Parse and show feed titles
doc.LoadXml(xmlFeed);
nodeList = doc.SelectNodes("//title"); // XPath expression, all titel elements
titleEnum = nodeList.GetEnumerator();
while(titleEnum.MoveNext())
{
title = titleEnum.get_Current();
value = title.get_FirstChild(); // text node is first child of parent title element
info(value.get_Value());
}


[[Image:Rssfeedtitle.PNG‎]]


[[Category:.NET Development]]


Источник: http://www.axaptapedia.com/Load_Web_Documents
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору.