Passing XMLDocument as parameter to XSLT

2019-08-04 03:23发布

问题:

I would like to pass the XMLdocument itself as parameter to the XSLT (without saving the XML physically). Is there any way to do that. My function accepts two Xmldocument and need to create new XML based on the two XML.

回答1:

The transform accepts an XmlReader; you can create an XmlNodeReader (which suffices) for any element in your DOM (typically the document element).



回答2:

You would be better off just combining your xml document nodes and transforming on the entire thing. There are ways to pass xml in as parameters but none of them are pretty and after you do it, you're still going to be forced to so some xsl trickery to gain access to it.



标签: .net xslt