I am using classic "ASP" dont bea me up. Just havent been able to make the jump to .Net yet. I am just learning soap and have successfully creates a SOAP request to a webservice. However, I am unable to figure out how to parse the response and pull out a single node. I am using MS DOM to load the response into a Document. I can get the response to screen. I have tried the following but I am unable to get to any nodes_text individually.
'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.
x开发者_运维百科mlDoc.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
Here is a response I am trying to parse
<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>
I need to pull the session_id from this pare but just dont seem to be able to do it. And yes I am looking to move to .NET soon.
If strResult is a URL to the xml file then you can use:
xmlDoc.Load(strResult)
But if strResult represents the content of xml, you need to use:
xmlDoc.LoadXML(strResult)
For more information, please refer to MSDN.
精彩评论