如何截取网页中的内容并循环输出
如下代码中,想截取<itme>与</itme>中的<time>2013-06-29</time>时间,并循环输入所有的时间。
<?xml version="1.0" encoding="UTF-8" ?>
- <TrackResult>
<message>完成</message>
<nu>123456</nu>
- <data>
- <itme>
<time>2013-06-28</time>
<context>提交</context>
</itme>
- <itme>
<time>2013-06-29</time>
<context>处理中</context>
</itme>
- <itme>
<time>2013-06-30</time>
<context>完成</context>
</itme>
</data>
<state>1</state>
<condition>7</condition>
</TrackResult>
[解决办法]
url="http://www.xxx.com"
'str=getHTTPPage(url)
'测试用的字符串,实际引用注释掉
str="<itme> <time>2013-06-28</time> <context>提交</context> </itme><itme> <time>2013-06-29</time> <context>处理中</context> </itme>"
content=""
set rx=new RegExp
rx.Global=true
rx.IgnoreCase=true
rx.Pattern="<time>([^<]+)</time>"
set mc=rx.Execute(str)
for i=0 to mc.count-1
content=content&"<br/>"&mc(i).submatches(0)
next
set rx=nothing
response.write content