XSLT of data extracted via XPath?
-
I know this really shouldn't be defeating me, but... I have a page where i'm using XSLT to transform a simple XML document (forum postings). This works fine, but if I want to display just one topic, i'm finding myself stuck. Using c# I can create an XmlNodeList containing the XML that I want, by performing a SelectNodes on an XmlDocument. This gives me the right data back, my XPath expression is fine. But! How do I then apply an XSL transform to that resulting nodelist? XSLT on seems to like XMLDocs, etc. Can I convert a NodeList to a Doc? I'm really stuck! Am I going about this the wrong way? Any help, or hints, anything, would be very gratefully received!
-
I know this really shouldn't be defeating me, but... I have a page where i'm using XSLT to transform a simple XML document (forum postings). This works fine, but if I want to display just one topic, i'm finding myself stuck. Using c# I can create an XmlNodeList containing the XML that I want, by performing a SelectNodes on an XmlDocument. This gives me the right data back, my XPath expression is fine. But! How do I then apply an XSL transform to that resulting nodelist? XSLT on seems to like XMLDocs, etc. Can I convert a NodeList to a Doc? I'm really stuck! Am I going about this the wrong way? Any help, or hints, anything, would be very gratefully received!
You can use for-each statement in xslt and loop thru in xslt. But anyway you have to pass XMLDocument, not XMLNodeList. Pass the XPath as a parameter to XSLT or you can hardcode in xslt if it doesnt change. You can check MSND for how to use for-each statement and Passing parameters to XSLT.