accessing XML variable in ASP


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: accessing XML variable in ASP

  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)

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