Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Printing a XML Response To The Screen

Status
Not open for further replies.

Krus1972

Programmer
Mar 18, 2004
145
0
0
US
Hi,

I am posting data to a server using XML and using ASP POST method. The server then sends a response back in XML format. Can someone tell me how I can simply take the raw XML RESPONSE and print it to the screen and include all of the XML nodes? Here is the function and the rest of the code I am using:


Function PostXmlRequest(xmlDoc, verb)

'Create a new ServerXMLHTTP object to post the request and get
the response
set xmlRequest = Server.CreateObject("MSXML2.ServerXMLHTTP")

'** set method and server URL
xmlRequest.open "POST", ServerUrl

'** Set the required HTTP Headers for the request
xmlRequest.setRequestHeader "Content-Type", "text/xml"

'** Regulates versioning of the XML interface for the API
xmlRequest.setRequestHeader "X-API-COMPATIBILITY-LEVEL", "759"
xmlRequest.setRequestHeader "X-API-DEV-NAME", DevID
xmlRequest.setRequestHeader "X-API-APP-NAME", AppID
xmlRequest.setRequestHeader "X-API-CERT-NAME", CertID
xmlRequest.setRequestHeader "X-API-CALL-NAME", verb
xmlRequest.setRequestHeader "X-EBAY-API-SITEID", "0"

'** send the request
xmlRequest.send xmlDoc

If xmlRequest.status = 200 then
set PostXmlRequest = xmlRequest.responseXML
else
set PostXmlRequest = nothing
End If

End Function





'*** Load the XML Request template from file
set xmlRequestDoc = Server.CreateObject("MSXML2.DOMDocument")
xmlRequestDoc.load(Server.MapPath("request.xml"))

'*** SET VARIOUS XML NODE VALUES

'*** Set the different node values in the input file:
xmlRequestDoc.selectSingleNode("//GetProductsRequest/IncludeBuyingGuideDetails").text = "true"
xmlRequestDoc.selectSingleNode("//GetProductsRequest/IncludeHistogram").text = "true"
xmlRequestDoc.selectSingleNode("//GetProductsRequest/IncludeItemArray").text = "false"
xmlRequestDoc.selectSingleNode("//GetProductsRequest/IncludeReviewDetails").text = "true"
xmlRequestDoc.selectSingleNode("//GetProductsRequest/ProductSearch/QueryKeywords").text = thesearch

xmlRequestDoc.selectSingleNode("//GetProductsRequest/Pagination/EntriesPerPage").text = EntriesPerPage

xmlRequestDoc.selectSingleNode("//GetProductsRequest/Pagination/PageNumber").text = PageNumber

'*** Send the Request and Get Response (with Detail Level "0")

set xmlResponse = PostXmlRequest(xmlRequestDoc, "GetProducts")

'*** Check Response exists
if xmlResponse is nothing then
Response.Write("Request could not be completed")
else
'Get response into an Xml Document object
set xmlResponseDoc = Server.CreateObject("MSXML2.DOMDocument")
xmlResponseDoc.loadXml(xmlResponse.xml)




 
response.write the output from the function.


Chris.

Indifference will be the downfall of mankind, but who cares?
Time flies like an arrow, however, fruit flies like a banana.
Webmaster Forum
 
Could you post syntex on how to do this?

Thanks
 
Same way you print output from any function.

response.write(PostXmlRequest(xmlDoc, verb))


Chris.

Indifference will be the downfall of mankind, but who cares?
Time flies like an arrow, however, fruit flies like a banana.
Webmaster Forum
 
That doesn't work.

How can I simply write the raw XML output to the screen that includes all of the node names right after this part of the code excutes. I would like to simply print it from the XML Document Object that's created here:

'** Get response into an Xml Document object

set xmlResponse = PostXmlRequest(xmlRequestDoc, "GetProducts")
Set xmlResponseDoc = Server.CreateObject("MSXML2.DOMDocument")xmlResponseDoc.loadXml(xmlResponse.xml)


I definatly appreciate your help.



I reall
 
Can anyone else help me with this?

Thanks.
 
Convert the < & > to HTML entities as you send it to the useragent and wrap it in a <pre> </pre> element to preserve the formatting.


Chris.

Indifference will be the downfall of mankind, but who cares?
Time flies like an arrow, however, fruit flies like a banana.
Webmaster Forum
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top