How can I pass XML (including nodes) to a C# method in XSLT?

H

Hvid Hat

How can I pass XML (including nodes) to a C# method in XSLT and process the
XML?

<msxsl:script language="C#" implements-prefix="user"><![CDATA[
public string processXml(/* WHAT DATA TYPE? */)
{
// How do I process the XML? I'd like to use .getElementById or something
similar if possible? I read something about using XPathNodeIterator.
return "";
}
]]></msxsl:script>

....
....
....

<xsl:template match="Documents">
<xsl:value-of select="user:processXml(.)" />
</xsl:template
 
M

Martin Honnen

Hvid said:
How can I pass XML (including nodes) to a C# method in XSLT and process
the XML?

<msxsl:script language="C#" implements-prefix="user"><![CDATA[
public string processXml(/* WHAT DATA TYPE? */)
{
// How do I process the XML? I'd like to use .getElementById or
something similar if possible? I read something about using
XPathNodeIterator.
return "";

The type should be XPathNodeIterator, that way you can pass in an
XSLT/XPath node-set. In your function you can then iterate e.g.
public string processXml (XPathNodeIterator it) {
while (it.MoveNext()) {
// ...
}
// need to return a string here to match the return type
// but it is not clear what kind of string you want to construct
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,982
Messages
2,570,190
Members
46,736
Latest member
zacharyharris

Latest Threads

Top