SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Enthusiast Mark_Elford's Avatar
    Join Date
    Oct 2003
    Location
    England, Wiltshire
    Posts
    74
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    XML HTTPRequest.

    Hi,

    Can anyone help or point me in the right direction, I am looking to read an external xml resource via an httprequest (I think), but I can't get my teeth sunk in just yet.?

    I need the request to be called via asp and then build an XML document that I can read via XSLT.

    So far, I have

    Code:
     
    myXMLdata = "http://mydatasource.co.uk/xml/qa/srch/?q=" + Search + "&p=0&pp=10" 
     
    Set xmlDoc=Server.CreateObject("Microsoft.XMLDOM") 
    xmlDoc.async=false
    xmlDoc.Open(Get,myXMLdata,async)
     
     
    If xmlDoc.parseError.errorcode <> 0 then 
    	'error handling code 
    	Response.Write(xmlDoc.parseError.errorcode) 
    Else 
    	'proceed '
    	for each x in xmlDoc.childNodes 
    	 response.Write x.NodeName 
    	next 
    End If
    However having problems with this bit xmlDoc.Open(Get,myXMLdata,async) I think

  2. #2
    SitePoint Wizard
    Join Date
    Nov 2004
    Location
    Nelson BC
    Posts
    2,310
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    First of all you want to use a XMLHTTP or ServerXMLHTTP object to do this.

    Secondly, the value of the first parameter of the open method should be a string and the third a boolean.

    Thirdly, you need to call the send method.

    Try
    Code:
    myXMLdata = "http://mydatasource.co.uk/xml/qa/srch/?q=" + Search + "&p=0&pp=10" 
     
    Set xmlDoc=Server.CreateObject("MSXML2.ServerXMLHTTP") 
    ' xmlDoc.async=false >> this doesn't do it
    xmlDoc.open "GET", myXMLdata, False
    xmlDoc.send

  3. #3
    SitePoint Enthusiast Mark_Elford's Avatar
    Join Date
    Oct 2003
    Location
    England, Wiltshire
    Posts
    74
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks Jim.

    So what I am really doing is creating an XML object rather than a document.?
    And I am then filling the object with the get method..

    But that method isnt actually run untill I call the .send cmd.


    I guess I then use the xmlDoc.responseText to populate my xmlDocument.

    I already have an XML document that I want to append the data to is there a quick way to populate the entire contents of the xmlObject into the existing document. Or do I need to read through the object?

    Pointers or a source of info would help greatly.. Thanks..
    Last edited by Mark_Elford; Dec 1, 2006 at 10:38. Reason: Update.

  4. #4
    SitePoint Wizard
    Join Date
    Nov 2004
    Location
    Nelson BC
    Posts
    2,310
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    have a look at this
    Code:
    myXMLdata = "http://mydatasource.co.uk/xml/qa/srch/?q=" + Search + "&p=0&pp=10" 
     
    ' Get xml document from somewhere
    Set xmlHTTP = Server.CreateObject("MSXML2.ServerXMLHTTP") 
    xmlHTTP.open "GET", myXMLdata, False
    xmlHTTP.send
    
    ' Make sure we got a valid xml document from xmlHTTP
    Set oError = xmlHTTP.responseXML.parseError
    If oError.errorCode <> 0 Then
    	Response.Write "Error - " & oError.reason
    	Response.End
    End If
    Set oError = Nothing
    
    ' load our other XML document
    Set xmlDoc = Server.CreateObject("MSXML2.DOMDocument")
    xmlDoc.async = False
    xmlDoc.load "c:\somexmldoc.xml"
    
    ' append the root node of responseXML to our document's root node
    xmlDoc.documentElement.appendChild xmlHTTP.responseXML.documentElement.cloneNode(true)
    
    ' now everything is contained in xmlDoc and we can chuck out xmlHTTP
    Set xmlHTTP = Nothing
    
    ' do stuff with xmlDoc

  5. #5
    SitePoint Member
    Join Date
    Dec 2006
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    damn it, you just made an error

  6. #6
    SitePoint Enthusiast Mark_Elford's Avatar
    Join Date
    Oct 2003
    Location
    England, Wiltshire
    Posts
    74
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sorry for the late reply, but better late than never. Jim that last post was exactly what I needed. I am now well on the way.. Many Thanks.

  7. #7
    Afrika
    Join Date
    Jul 2004
    Location
    Nigeria
    Posts
    1,737
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hi,
    here is Another excellent server object

    Dim afrika
    Set afrika=CreateObject("WinHttp.WinHttpRequest.5.1")
    afrika.Open "GET", sendsms, False
    afrika.Send


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •