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;
Palec
  • 12,743
  • 8
  • 69
  • 138
Freexel
  • 53
  • 5

2 Answers2

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.

Stephen Quan
  • 21,481
  • 4
  • 88
  • 75
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)
Dee
  • 1,432
  • 1
  • 9
  • 8