Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Getting XML values into a ASP page?

Options
  • 20-09-2005 2:47pm
    #1
    Registered Users Posts: 5,102 ✭✭✭


    Hi,
    I have an XML file with data like this ...

    <St4>
    <InsuranceContract>
    <NumberofContracts THREE="11" TWO="11"/>
    <PremiumWritten THREE="11" TWO="11"/>
    </InsuranceContract>
    <Claims>
    <NumberofClaims THREE="11" TWO="11"/>
    <GrossClaimsPaid THREE="11" TWO="11"/>
    </Claims>
    </St4>
    <St5>
    <InsuranceContract>
    <NumberofContracts THREE="11" TWO="11"/>
    <PremiumWritten THREE="11" TWO="11"/>
    </InsuranceContract>
    <Claims>
    <NumberofClaims THREE="11" TWO="11"/>
    <GrossClaimsPaid THREE="11" TWO="11"/>
    </Claims>
    </St5>
    <St6>
    <InsuranceContract>
    <NumberofContracts FOUR="11" THREE="11" TWO="11"/>
    <PremiumWritten FOUR="11" THREE="11" TWO="11"/>
    </InsuranceContract>
    <Claims>
    <NumberofClaims FOUR="11" THREE="11" TWO="11"/>
    <GrossClaimsPaid FOUR="11" THREE="11" TWO="11"/>
    </Claims>
    </St6>

    etc...

    Now I can get the XML file to be limited in what values it displays by putting this at the top of it

    <?xml version="1.0" encoding="UTF-8"?>
    <?xml-stylesheet type="text/xsl" href="QuarterlyInsuranceReturn.xsl"?>

    and having this content in the XSL file

    <?xml version="1.0" encoding="ISO-8859-1"?>
    <xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&gt;

    <xsl:output method='html' version='1.0' encoding='UTF-8' indent='yes'/>
    <xsl:template match="/">
    <html>
    <head></head>
    <body>
    <p>The Form elements are:</p>
    <ul>

    <xsl:apply-templates select="/QuarterlyInsuranceReturn/St1/InsuranceContract/NumberofPolicies"/>
    <xsl:apply-templates select="/QuarterlyInsuranceReturn/St2/InsuranceContract/NumberofPolicies"/>

    </ul>



    </body>
    </html>
    </xsl:template>


    <xsl:template match="/QuarterlyInsuranceReturn/St1/InsuranceContract/NumberofPolicies">
    <li><font color='red'><xsl:value-of select="@FIVE&quot;/></font></li>
    <li><font color='red'><xsl:value-of select="@FOUR&quot;/></font></li>
    </xsl:template>
    <xsl:template match="/QuarterlyInsuranceReturn/St2/InsuranceContract/NumberofPolicies">
    <li><font color='red'><xsl:value-of select="@FIVE&quot;/></font></li>
    <li><font color='red'><xsl:value-of select="@FOUR&quot;/></font></li>
    </xsl:template>

    </xsl:stylesheet>


    But my question is - Is there a way to get that data from a ASP page?
    Is there a way to take a value from an XSL file and print it in the VBSCRIPT in the ASP?
    Thanks!
    M


Comments

  • Registered Users Posts: 131 ✭✭theexis


    I'm not totally clear what you mean "get it from an ASP page", but assuming you mean when a user hits the page, you want to load and transform XML just instantiate an XmlDocument in VBSCRIPT, load the XML data document, and stream back the results of document.Transform.


  • Registered Users Posts: 5,102 ✭✭✭mathie


    theexis wrote:
    I'm not totally clear what you mean "get it from an ASP page", but assuming you mean when a user hits the page, you want to load and transform XML just instantiate an XmlDocument in VBSCRIPT, load the XML data document, and stream back the results of document.Transform.

    Sorry to clarify what I finally wish to do is in my ASP execute some SQL queries.

    These queries will be created in the XSL (not sure if thats best though) and executed in the ASP.

    The question I was hoping to have initially answered was is it possible to take a value from the XML file and be able to equate it to a variable in ASP?
    Like the XML value

    <xsl:template match="/QuarterlyInsuranceReturn/St1/InsuranceContract/NumberofPolicies">
    <li><font color='red'><xsl:value-of select="@FIVE&quot;/></font></li>

    Could I have that value in a variable in my ASP?
    Hope this helps
    M


  • Registered Users Posts: 2,781 ✭✭✭amen


    yes you can
    assign a variable to the xml path in ASP(vbscript)
    and extract the value that you want using a syntax such as
    myVariable =myXML.fetNamedItem("Five").nodeValue
    if you need more help then post specifics
    bit busy today otherwise I'd give a better example


Advertisement