Getting an XML attribute


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: Getting an XML attribute

  1. #1
    Join Date
    Mar 2011
    Posts
    1

    Getting an XML attribute

    I am using aspx to send a XML request to an ‘engine’ which will send me back a response:
    Code:
    <%
    Dim URL
    Dim XMLHTTP
    Dim sRequest
    Dim sServerNode
    Dim URLEncoder 
    Dim result
    
    ‘**** XML Data ****
     sRequest = "<eLoginRequest ClientType='Win32' CurrentSAP='0' Locale='eng'><FieldInputList><FieldInput Field='username'>Richard</FieldInput><FieldInput Field='password'>D41D8CD98F00B204E9800998ECF8427E</FieldInput></FieldInputList></eLoginRequest>"
    sServerNode = "<Engine Name='Engine'><Transport Type='DCOM'><Server>localhost</Server></Transport></Engine>"
    
    ‘**** Engine URL ****
    url = "http://localhost/escripts/eMessageHandler.dll" 
    
    xmlhttp = CreateObject("Microsoft.XMLHTTP") 
    xmlhttp.open ("Get", url, false) 
     xmlhttp.send ("ServerNode=" & Server.URLEncode(sServerNode) & "&Request=" & Server.URLEncode(sRequest)) 
    
    **** Writes the XML response to the page *****
    Response.write (xmlhttp.responseText)
    
    **** To be used to get the XML Attributes *****
    xmlDoc= xmlhttp.responseXML
    
    %>
    The XML Response sent back is:

    <eLoginResponse Timestamp="2011-03-31T16:01:24" SessionID="BCFEC70C-55CD-45A2-A34C-60301EEB7D5C" OldestDeletion="2011-03-21T21:31:10" UserID="Richard"><ClientData/></eLoginResponse>

    What I want to do is display the attribute: ‘SessionID’ on the screen, either assign the session ID value to a variable or to a text box value. So far I am using the code below but I am stuck on how this can be done:
    Code:
    <%
    dim xmlDoc
    dim i
    
    xmlDoc= xmlhttp.responseXML
    dim x = xmlDoc.getElementsByTagName("SessionID")
    Response.write(x)
    
    %>
    The code above will print the following to the screen: System.__ComObject
    I have also tried using x.xmlObj.childNodes(0).getAttribute("SessionID") but I get the following error: Identifier expected.

  2. #2
    Join Date
    Oct 2008
    Posts
    142
    hi there,

    to print this values, maybe you need

    Code:
    Response.write(x.Text)
    instead of

    Code:
    Response.write(x)
    good luck,

    tonci.

Similar Threads

  1. Replies: 0
    Last Post: 10-20-2009, 10:45 AM
  2. Replies: 2
    Last Post: 11-26-2007, 11:06 AM
  3. Try XML Junction
    By Tim in forum xml.announcements
    Replies: 0
    Last Post: 10-11-2001, 05:00 PM
  4. XML Startkabel Updates
    By xmlstartkabel in forum XML
    Replies: 0
    Last Post: 10-10-2001, 05:07 AM
  5. Data Junction Announces XML Junction 7.51
    By Tim Frost in forum xml.announcements
    Replies: 0
    Last Post: 04-02-2001, 11:53 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center