In my XML, I have something like this:
<people>
<person>
<name>
<first>Bob</first>
<last>Bobbertson</last>
</name>
<age>80</age>
</person>
...
</people>
I want to be able to pass the entire <person> section to my code-behind so that in my C# code, I can have access to all of the subnodes (<name>, <first>, <last>).
I am using XSLT to generate my HTML, and in my XSLTfile, I have a line like this:
<xsl:value-of select="custom:SelectPerson($selectedPerson)"/>
Which calls this in my code-behind:
public string SelectPerson(System.Xml.XPath.XPathNodeIterator selectedPersonNodes)
{
foreach (var node in selectedPersonNodes)
{
Debug.WriteLine(node.ToString());
}
...
}
What I want to happen is to have the foreach loop three times, and print out "Bob", then "Bobbertson", then "80". But what is happening is that it goes through once and prints out "BobBobbertson80".
Is there a way to pass the nodes in the way I want from the XSLT-generated HTML to my code-behind?