티스토리 뷰
jython에서는 substring과 같은 문자열 처리가 없다.
근데 onetime url 획득 후 데이터 확인해야 한다면?
결과물이 xml이라면 아래와 같은 방식으로 xmlData를 추출할수 있다.
출처 : http://www.travisglines.com/web-coding/python-xml-parser-tutorial
#import library to do http requests: import urllib2 #import easy to use xml parser called minidom: from xml.dom.minidom import parseString #all these imports are standard on most modern python implementations #download the file: file = urllib2.urlopen('http://www.somedomain.com/somexmlfile.xml') #convert to string: data = file.read() #close file because we dont need it anymore: file.close() #parse the xml you downloaded dom = parseString(data) #retrieve the first xml tag (data ) that the parser finds with name tagName: xmlTag = dom.getElementsByTagName('tagName')[0].toxml() #strip off the tag (data ---> data): xmlData=xmlTag.replace('','').replace(' ','') #print out the xml tag and data in this format:data print xmlTag #just print the data print xmlData
'Tech > Cording' 카테고리의 다른 글
[C++] Vista 이상에서 Service에서 활성화된 세션 ID로 특정 어플리케이션 실행하기 (0) | 2013.11.25 |
---|---|
[C++] 트레이에 아이콘 등록하기 (0) | 2013.11.25 |
rand() 함수에 대해서... (2) | 2008.04.25 |
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크
TAG
- 왕좌의 게임
- 연성결
- tcp_retries2
- 설산비호
- 백마소서풍
- 스웰시즌
- 협객행
- http live streaming
- swell
- 월녀검
- 정규분포
- 백혈검
- THE SWELL SEASON
- rsync
- 서검은구록
- 원양도
- 원스
- Glen Hansard
- CLOSE_WAIT
- 메르센 트위스터
- 홍대앞 놀이터
- mediastreamvalidator
- Mersenne Twister
- 홍대 프리마켓
- 공연후기
- game of thrones
- rand
- ONCE
- Marketa Irglova
- srand
글 보관함