목적은 웹서비스로 XML 문서를 가져와서 파싱하여 필요로 하는 노드의 정보만 가져오는 것이다.
이를 위한 코드는 다음과 같다.
// url 작성
string url = ConfigurationManager.AppSettings["approval_url"] + "?FormKey=" + formKey + "&EmpNo=" + ConfigurationManager.AppSettings["emp_no"]; ;
// http 연결하여 xml 문서 가져오기
WebRequest wrGETURL = WebRequest.Create(url);
using (StreamReader reader = new StreamReader(wrGETURL.GetResponse().GetResponseStream()))
{
// XML 결과값 읽기
String xml = String.Empty;
String sLine = String.Empty;
while (sLine != null)
{
sLine = reader.ReadLine();
if (sLine != null)
xml += sLine;
}
// XML 문서 생성
XmlDocument doc = new XmlDocument();
doc.LoadXml(xml);
XmlElement root = doc.DocumentElement;
// IA_KEY 노드만 가져옴
XmlNodeList nodes = root.GetElementsByTagName("IA_KEY");
if (nodes == null || nodes.Count <= 0)
continue;
foreach (XmlNode node in nodes)
{
if (iaKeyList == null)
{
iaKeyList = new List();
}
// IA_KEY 의 값만 입력
iaKeyList.Add(node.InnerText);
}
}
반응형
'프로그래밍 언어 > .Net' 카테고리의 다른 글
| .Net 의 오라클 커넥션을 이용할 때 select 문 처리중 delete 문을 이용하면 어떻게 될 까? (0) | 2013.04.25 |
|---|---|
| .Net에서 오라클 DB Select 하기 (0) | 2013.04.25 |
| .Net ASP에서 Web.config의 appSettings, connectionStrings 활용하기 (0) | 2013.04.24 |
| .Net에서 오라클 DB에 데이터 insert와 트랜잭션 처리 (1) | 2013.04.24 |
| Oracle.DataAccess 과 System.Data.OracleClient 의 차이 (0) | 2013.04.23 |