A despert newbie needs help

I have an ASP (vbscript) page that accepts XML posts from an external web site.

The XML they post is:

<TOKEN>
<TICKET GUID="This is the value I need to get"></TICKET>
<TIMESTAMP>xxxxxxxxxxxx</TIMESTAMP>
<TOKEN>

How can I read the GUID value in ASP code

Thanks.



Answer this question

A despert newbie needs help

  • LukeR_

    What does xmlDom.load(Request) return (In general, it's a good idea to check return values of the methods you are calling.) If it returns false, you have to check the parseError property, see Derek's sample above. If it returns true, check whether the root element is really TOKEN. The XPath expression is correct.

    Best regards,
    Anton


  • Rob Mijnen

    Hi,

    You'll need to use the objects in MSXML to run an XPath query on the data.

    var xmlDoc = new ActiveXObject("Msxml2.DOMDocument.4.0");
    var currNode;
    xmlDoc.async = false;
    xmlDoc.resolveExternals = false;
    xmlDoc.load("books.xml");
    if (xmlDoc.parseError.errorCode <> 0) {
       var myErr = xmlDoc.parseError;
       alert("You have error " + myErr.reason);
    } else {
       xmlDoc.setProperty("SelectionLanguage", "XPath");
       currNode = xmlDoc.selectSingleNode("/TOKEN/TICKET/@GUID");
       alert(currNode.text);
    }

    The other way you could do it is treat the xml as text and use string functions to extract the text. You could use regular expressions to find the text your looking for.



  • Yogesh S

    The request is the XML I posted earlier:

    <TOKEN>
    <TICKET GUID="This is the value I need to get"></TICKET>
    <TIMESTAMP>xxxxxxxxxxxx</TIMESTAMP>
    <TOKEN>

    Do I have to call
    xmlDoc.setProperty("SelectionLanguage", "XPath");


  • Frank Carr

    I'm using this but still is not working

    Dim xmlDom
    Dim xmlNode

    Set xmlDom = CreateObject("Microsoft.XMLDOM")
    xmlDom.async = false
    xmlDom.load(Request)

    Set xmlNode = xmlDom.SelectSingleNode("/TOKEN/TICKET/@GUID")

    If Not xmlNode Is Nothing Then
    ReadXMLRequest = xmlNode.text
    else
    ReadXMLRequest = ""
    end if

    Set xmlDom = nothing

    Are you sure /TOKEN/TICKET/@GUID is the right path


  • Mendip162

    This XML is not well-formed, since TOKEN tags are not closed. When I replaced the last <TOKEN> with </TOKEN>, Derek's script worked just fine.


  • A despert newbie needs help