VBScript:
Dim xmlDoc
Set xmlDoc = CreateObject ( " Microsoft.XMLDOM " )
xmlDoc.async = false
xmlDoc.load( " http://172.16.168.33:8012/getstatus.php?username= " & userName)
If xmlDoc.ReadyState > 2 Then ' 读取完毕
Set myitem = xmlDoc.getElementsByTagName( " Result " ) ' 读取Result标记
strStatus = myitem.item( 0 ).text
set xmlDoc = nothing
end if
Set xmlDoc = CreateObject ( " Microsoft.XMLDOM " )
xmlDoc.async = false
xmlDoc.load( " http://172.16.168.33:8012/getstatus.php?username= " & userName)
If xmlDoc.ReadyState > 2 Then ' 读取完毕
Set myitem = xmlDoc.getElementsByTagName( " Result " ) ' 读取Result标记
strStatus = myitem.item( 0 ).text
set xmlDoc = nothing
end if
XML格式如下:
<? xml version="1.0" encoding="gb2312" ?>
- < Root >
< Result > -1 </ Result >
</ Root >
- < Root >
< Result > -1 </ Result >
</ Root >
ASP:
Set http = Server.CreateObject( " Microsoft.XMLHTTP " )
http.Open " GET " , " http://localhost/xml.xml " , False
http.send
Set xml = Server.CreateObject( " Microsoft.XMLDOM " )
xml.Async = False
xml.ValidateOnParse = False
xml.Load(http.ResponseXML)
If xml.ReadyState > 2 Then
Response.Write( " 文档已经准备就绪。状态: " & xml.ReadyState & " <br> " )
Set item = xml.getElementsByTagName( " item " )
For i = 0 To (item.Length - 1 )
Set title = item.Item(i).getElementsByTagName( " title " )
Set link = item.Item(i).getElementsByTagName( " link " )
Response.Write( " <a href="" target="_blank" rel="external nofollow" " & link.Item( 0 ).Text & " ""> " & title.Item( 0 ).Text & " </a><br> " )
Next
Else
Response.Write( " 文档还未准备就绪。状态: " & xml.ReadyState & " <br> " )
End If
Set http = Nothing
Set xml = Nothing
http.Open " GET " , " http://localhost/xml.xml " , False
http.send
Set xml = Server.CreateObject( " Microsoft.XMLDOM " )
xml.Async = False
xml.ValidateOnParse = False
xml.Load(http.ResponseXML)
If xml.ReadyState > 2 Then
Response.Write( " 文档已经准备就绪。状态: " & xml.ReadyState & " <br> " )
Set item = xml.getElementsByTagName( " item " )
For i = 0 To (item.Length - 1 )
Set title = item.Item(i).getElementsByTagName( " title " )
Set link = item.Item(i).getElementsByTagName( " link " )
Response.Write( " <a href="" target="_blank" rel="external nofollow" " & link.Item( 0 ).Text & " ""> " & title.Item( 0 ).Text & " </a><br> " )
Next
Else
Response.Write( " 文档还未准备就绪。状态: " & xml.ReadyState & " <br> " )
End If
Set http = Nothing
Set xml = Nothing
xml.xml文档的内容如下:
<? xml version="1.0" encoding="utf-8" ?>
< channel >
< item >
< title > 测试文档1 </ title >
< link > http://localhost/ </ link >
</ item >
< item >
< title > 测试文档2 </ title >
< link > http://localhostindex.asp </ link >
</ item >
</ channel >
<? xml version="1.0" encoding="utf-8" ?>
< channel >
< item >
< title > 测试文档1 </ title >
< link > http://localhost/ </ link >
</ item >
< item >
< title > 测试文档2 </ title >
< link > http://localhostindex.asp </ link >
</ item >
</ channel >