DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 2 of 2
  1. #1
    Join Date
    Aug 2004
    Posts
    43,023

    accessing XML variable in ASP

    [Originally posted by Ben]

    How do I set an ASP variable to the value of an XML variable? For example, the XML variable defined as:

    < xsl:variable name = "maxX">
    ÿ < xsl:for-each select = "//@Xpos">
    ÿ ÿ < xsl:sort data-type = "number" order="descending" />
    ÿ ÿ < xsl:if test="position()=1">
    ÿ ÿ ÿ < xsl:value-of select="."/>
    ÿ ÿ < /xsl:if>
    ÿ < /xsl:for-each>
    < /xsl:variable>

    I would like to set the ASP variable something like this:

    dim theMax
    ÿÿ theMax = Request.xmlvariable($maxX)

    response.write(theMax)

    I know this is wrong but I think it can be done something like this. Can anybody help?? Thanks

    Ben

  2. #2
    Join Date
    Aug 2004
    Posts
    43,023

    Re:accessing XML variable in ASP

    [Originally posted by mike]

    first you need to load the XML data into the XML DOM "Document Model" object. Then, walk thru the DOM instance like you would go thru a Treeview control.

    But, if you know that there will always be only 1 instance of the data you need to get, then you could do a quick and nasty substring search. Something like:

    StartAt = Instr(theXML, "<SOMETAGNAME>")
    EndAt = Instr(StartAt, theXML, "<")
    MyValue = CInt(Mid(theXML, StartAt, (EndAt - StartAt))

    (I do this method alot - its faster, but is prone to problems if the XML structure is likely to change)

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
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links