XML:

<?xml version="1.0" encoding="iso-8859-1" ?>
<results> <result> <ip>111.93.167.67</ip> <host /> <isp>Tata Teleservices ISP</isp> <org>Tata Teleservices ISP</org> <region>Calcutta</region> <countrycode>IN</countrycode> <latitude>22.569700241089</latitude> <longitude>88.369697570801</longitude> <queries>2</queries> </result> </results>

  

APEX:

public class OrgInfo_XmlStreamReader {

	public String org{get;set;}

	public List<String> XMLData{get;set;}

	public OrgInfo_XmlStreamReader(){

	   XMLData=new List<String>();

	}

	public List<String> getOrganisationInfo(String ip){ 

			Http http = new Http();

			HttpRequest req = new HttpRequest();

			req.setEndpoint('http://xml.utrace.de/?query='+ip);

			req.setMethod('GET');

			HttpResponse res = http.send(req);

			// Log the XML content

			String xmlContent=res.getBody();

			System.debug(res.getBody());

			System.debug('#####XmlStreamReader ##11##');

			// Generate the HTTP response as an XML stream

			XmlStreamReader reader = res.getXmlStreamReader();

			System.debug('##########XML DATA##########'+res.getXmlStreamReader());

			XMLData=XMLParser(res.getBody());

			return XMLData;

	}

	public List<String> XMLParser(String strXml){

		System.debug('####Inside XMLParser Method########'+strXml);

		List<String> orgInfo=new List<String>();

		Dom.Document doc = new Dom.Document();

		doc.load(strXml);

		//Retrieve the root element for this document.

		Dom.XMLNode Envelope = doc.getRootElement();

		Dom.XMLNode Body= Envelope.getChildElements()[0];

		string user_createResult = '';

		for(Dom.XMLNode child : Body.getChildElements()) {

		   orgInfo.add(child .getText());

		}

		return orgInfo;

	}

}

  

最新文章

  1. FireFox每次访问页面时检查最新版本
  2. HashMap常用方法
  3. Objective-C之代理设计模式小实例
  4. Scrum Meeting---Nine(2015-11-4)
  5. js encodeURI方法认识
  6. 无需添加引用执行JS,发布无需带DLL、例子:QQMD5 QQGTK 13位时间戳 取随机数
  7. libcurl的使用问题“Expect100-continue”
  8. uvc摄像头代码解析6
  9. HDFS概述(4)————HDFS权限
  10. GeoServer+PostgreSQL+PostGIS+pgRouting实现最短路径查询
  11. linux C/C++开发环境搭建指南
  12. Python内置函数详解——总结篇
  13. python变量、条件循环语句
  14. hello随笔
  15. 第十九单元 nfs服务
  16. fiddler 中显示请求 IP
  17. Jquery中的 Deferred分析
  18. php 获取数组深度的值
  19. Delphi 简单命名管道在两个进程间通讯
  20. Google Protocol Buffers 反序列化 转

热门文章

  1. finally代码块-多异常的捕获处理
  2. 关于Vue2.x与Es6一些特性
  3. CentOS7 RPM方式安装JDK
  4. 2211-13 flask模板
  5. Redis避坑指南:为什么要有分布式锁?
  6. PID控制_位置式
  7. DELLR740服务器安装centos7.9操作系统时发现无法检测到硬盘
  8. Win10 局域网共享文件遇到的疑难杂症通用解决策略
  9. 网页实时显示已经运行了多少天 html+js
  10. Bus Stop