03.01.2009, 18:36 | #1 |
Участник
|
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, напишите личное сообщение администратору. |
|
03.01.2009, 23:50 | #2 |
Участник
|
1.
X++: public static void TEST_DownloadString (Args _args) { System.Net.WebClient webClient = new System.Net.WebClient(); ; info(webClient.DownloadString('http://axaptapedia.com')); } X++: static void Job8(Args _args) { XmlDocument doc = new XMLDocument(); XmlNodeList nodeList; XMLElement element; ; doc.load(@'http://www.axaptapedia.com/index.php?title=Special:Recentchanges&feed=rss'); nodeList = doc.selectNodes(@'//item'); for(element = nodeList.nextNode(); element; element = nodeList.nextNode()) { info(element.getNamedElement('title').text()); } } |
|
|
За это сообщение автора поблагодарили: mazzy (2), gl00mie (2), alex55 (1), kpoxa (1). |
|
Опции темы | Поиск в этой теме |
Опции просмотра | |
|