2

I will send some information from one site to another site. I have an XML generated, using the script below. How can I read the XML into readxml.asp?

var xmlServer = "http://www.****/readxml.asp";
var xmlStr = "";
xmlStr+='<hm>';
xmlStr+='<debnr>Debnr</debnr>';
xmlStr+='<date>'+getToday()+'</date>';
xmlStr+='<time>'+getTime()+'</time>';
xmlStr+='<ip>'+ipNum+'</ip>';
xmlStr+='</hm>';

var xmlhttp = Server.CreateObject ("MSXML2.ServerXMLHTTP");
xmlhttp.open ("POST", xmlServer, false);
xmlhttp.setRequestHeader("Content-Type", "text/xml")
xmlhttp.send(xmlStr);
var node = ""+xmlhttp.responseText;

2 Answers 2

2

Instead of var node I believe the code you're looking for is:

var xmldoc = CreateObject("Microsoft.XMLDOM");
xmldoc.loadXML(xmlhttp.responseText);

However, your code is rather dangerous in that the XML request you're sending could be invalid XML. For instance, if Debnr, getToday(), getTime() or ipNum contains invalid characters (e.g. if they themselves contain symbols like <, > or &) then the request you're building will be malformed. I recommend that the request be built using the XMLDOM too.

Sign up to request clarification or add additional context in comments.

Comments

0

I believe you can load XML data directly from ASP Request object if it is being sent from the client as follows :

 ' Load the specified XML file
 '------------------------------
  mydoc.load(Request)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.