开发者

Accessing XSL Variable with Classic ASP Code?

开发者 https://www.devze.com 2023-02-15 11:36 出处:网络
I am curious if there is anyway to access a XSL variable\'s data from ASP code.First some background information...

I am curious if there is anyway to access a XSL variable's data from ASP code. First some background information...

I have an ASPX page that is pulling data from an XML file, and using a separate classic ASP page for the "Response.write(mm_xsl.Transform())" aspect.

In the classic ASP page that dictates the HTML output to the viewer, I have XSL variables used to print certain data from the XML file. For example I use this code to initialize the variable:

<xsl:variable name="age" select="person/Age" />

And then this code to print/echo the variable:

{$age}

Let's say the value of the variable was 50. Is there anyway I can somehow pass "50" into an ASP variable? I realize I might need to get creati开发者_JAVA百科ve and somehow retrieve "50" from the markup, similar to client-side DOM parsing. Is there any server-side parsing method similar to this?

Any other ideas? Any tips or relevant links are greatly appreciated. Thanks!


Can't you just execute the same select you have in your xsl:variable statement in VBScript inline on the Classic Asp page?

Assuming your XML Document is called mm_doc you could try something like:

  dim age
  age = mm_doc.selectSingleNode("person/Age").text

and now you have an age variable with the same contents from your Xml Document.


You need to look into the MSXML documentation how to get the result of the transformation as a string (from either VBScript or JavaScript). I believe this is possible.

Then your XSLT transformation will just output the value of the variable (and nothing else).


As Dmitre said, you need to use MSXML, which is the XML plugin to ASP.

Tutorials and documentation are available at:

  • http://www.4guysfromrolla.com/webtech/10
  • http://www.aspfree.com/c/a/XML/MSXML-Tutorial/
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号