Microsoft MVP성태의 닷넷 이야기
Microsoft.XMLHTTP 개체로 XML 이 아닌 다른 데이터 가져오기 [링크 복사], [링크+제목 복사],
조회: 13061
글쓴 사람
정성태 (techsharer at outlook.com)
홈페이지
첨부 파일
 

보통 Microsoft.XMLHTTP 로 정형화된 XML 텍스트가 아니고서는 결과를 "깨진" 텍스트로 받게 됩니다.
그렇다고... 실제로 데이터가 엉뚱하게 변환되었을 리는 없을 테고.... 그냥 2진 데이터였겠죠.
 
아래의 코드에서 보면, 이진데이터를 아스키 코드로 변환해주는 VBScript 함수를 볼 수 있습니다.
 
그걸로, XMLHTTP::responseBody 속성을 해석해 주면,
정형화되지 않은 일반 텍스트 ( 한글포함 ) 문서까지도 정상적으로 반환받을 수 있습니다.
 
------ 뉴스그룹 보다가 퍼옴 ------
 


<html>
 
<head>
 
<script language=jscript>
function window.onload()
{
 var httpReq = new ActiveXObject( "Microsoft.XMLHTTP" );
 httpReq.open( "GET", "
http://webdic.ybmsisa.com/dic_search.asp", false );
 httpReq.send();
 
 alert( httpReq.responseBody );     // 여기서는 텍스트가 깨진체로 보여지지만.
 var text = BinDecode( httpReq.responseBody ); 
 alert( text );  // 여기서는 일반 ascii 텍스트로 번역되어 정상적으로 출력

}
</script>
 

<script language="vbscript">
'-----------------------------------------
' BinDecode (바이너리 -> 아스키 변환)
' mongmong - 2003. 2
'-----------------------------------------
 Public Function BinDecode(byVal binData)
  Dim i, byteChr, strV
  For i = 1 to LenB(binData)
   byteChr = AscB(MidB(binData,i,2))
   If byteChr > 127 Then
    i = i + 1
    strV = strV & Chr("&H" & Hex(byteChr) & Hex(AscB(MidB(binData,i,2))))
   Else
    strV = strV & Chr(byteChr)
   End if
  Next
  BinDecode = strV
 End Function
</script>
 

</head>
 
<body>
<FONT face="굴림"></FONT>
</body>
 
</html>







[최초 등록일: ]
[최종 수정일: 1/26/2004]


비밀번호

댓글 작성자
 




... 31  32  33  34  35  36  37  38  [39]  40  41  42  43  44  45  ...
NoWriterDateCnt.TitleFile(s)
213정성태4/13/200611164Introduction to the MSN Messenger Activity SDK
212정성태4/13/200613250FIN_WAIT_2 상태에 대하여
211정성태4/13/200611827Override CLR Assembly Probing Logic
210정성태4/13/200612224Web.config의 기본 <appSettings /> Handler 교체
209정성태3/25/200612085Win32 FileID API Library
208정성태4/13/200611588(거의)모든 DB 에 대한 ADO.NET Data Provider (유료)목록
205정성태4/13/200611742Static Code Analyzer
206정성태4/13/200611427    답변글 Visual C++ Express를 사용한 보안 응용 프로그램 빌드
203정성태4/13/200611142WGF (Windows Graphic Foundation) [1]
202정성태4/13/200611179사용자 컴퓨터 환경 조사 결과(외국 사례)
201정성태4/13/200616500MySQLDirect .NET Data Provider
207정성태4/13/200610678    답변글 무료: Download Connector/Net 1.0 (MySQL) [1]
200정성태4/13/200611189Understanding Classic COM Interoperability With .NET Applications파일 다운로드1
199정성태4/13/200611552How to get a V2.0 ICorDebug object
198정성태4/13/200611544Whidbey breaking change --- Caching binding failures [1]
197정성태4/13/200610922The JIT does dead-code elimination in Debuggable code
195정성태4/13/200610883910442 - Working with Web Resources in ASP.NET 2.0
194정성태4/13/200611493ASP.NET 2.0 WebPart - SQL Server Error 26: Error Locating Server/Instance Specified
193정성태4/13/200611543WCF - Breaking Changes between Jan CTP and Feb CTP파일 다운로드1
192정성태4/13/200611022Cassini Update
191정성태4/13/200612098LeechBlocker ISAPI Filter
189정성태4/13/200611271The New Anonymous Types Feature in C# 3.0 [1]
188정성태3/8/200611413Microsoft Anti-Cross Site Scripting Library V1.0
196정성태4/13/200610834    답변글 왜 사용해야 하는가?
187정성태4/13/200610799제 1회 INETA 세미나
186정성태4/13/200611353Internet Information Services (IIS) 6.0 Manager for Windows XP
... 31  32  33  34  35  36  37  38  [39]  40  41  42  43  44  45  ...