我正在使用经典的“ASP”不要让我失望。还没有能够跳转到.Net。我只是学习soap并成功创建了一个Web服务的SOAP请求。但是,我无法弄清楚如何解析响应并拉出单个节点。我正在使用MS DOM将响应加载到Document中。我可以得到屏幕的响应。我尝试了以下但我无法单独访问任何nodes_text。
'Set the XML Object
Set xmlDoc = Server.CreateObject("Microsoft.XMLDOM")
'Set Asynchoronous = false
xmlDoc.async = False
'Load the XML file.
'User Server.MapPath method is the XML is located in your site.
'Else you can use the absolute path.
xmlDoc.Load (strResult)
'If there is any errors pasring the file the notify
If xmlDoc.parseError.errorCode = 0 Then
Response.Write "Error Parsing XML"
Response.Write "Rason :" & xmlDoc.parseError.reason & "Error Line: " & xmlDoc.parseError.line
End If
'Get ALL the Elements by the tag name book
Set sessionid = xmlDoc.getElementsByTagName("session_id")
'Now Iterate through the List and Display
response.write"sessionid ="&sessionid&"<BR>"
For i = 0 to (sessionid.Length-1)
Response.Write "session_id " & sessionid.item(i).childNodes(0).text & "<br/>"
Next
以下是我要解析的回复
<ns:getSessionResponse xmlns:ns="http://services.axis.openmeetings.org">
<ns:return xmlns:ax217="http://basic.beans.data.app.openmeetings.org/xsd"
xmlns:ax218="http://basic.beans.hibernate.app.openmeetings.org/xsd"
type="org.openmeetings.app.hibernate.beans.basic.Sessiondata">
<ax218:id>71</ax218:id>
<ax218:language_id xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" />
<ax218:organization_id xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" />
<ax218:refresh_time>2010-11-04T15:17:13.717Z</ax218:refresh_time>
<ax218:sessionXml xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" />
<ax218:session_id>5f0415d9cdb72681816095debf3735de</ax218:session_id>
<ax218:starttermin_time>2010-11-04T15:17:13.717Z</ax218:starttermin_time>
<ax218:storePermanent xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" />
<ax218:user_id xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" />
</ns:return>
</ns:getSessionResponse>
我需要从这个削减中拉出session_id,但似乎无法做到这一点。是的,我希望尽快转向.NET。
答案 0 :(得分:0)
如果strResult是xml文件的URL,那么您可以使用:
xmlDoc.Load(strResult)
但是如果strResult表示xml的内容,则需要使用:
xmlDoc.LoadXML(strResult)
有关详细信息,请参阅MSDN。