I created an XML file and can successfully use that information to create a drop down list. What I would like to achieve is to add variables from a stringResource file to create the values for the drop down list.
my original XML file is:
<root>
<row>
<var name="--Select--"/>
</row>
<row>
<var name="Agriculture"/>
</row>
<row>
<var name="Airline"/>
</row>
<root>
in trying to add variables I have tried the following:
<PackageTransform>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:aspdnsf="urn:aspdnsf" exclude-result-prefixes="aspdnsf">
<xsl:output method="html" omit-xml-declaration="yes" />
<xsl:template match="row">
<xsl:param name="pReplacement" select="'Something Different'"/>
<root>
<row>
<xsl:value-of select="aspdnsf:StringResource('industry.cs.1')"/>
</row>
<row>
Air
</row>
<row>
<xsl:value-of select="$pReplacement" />
</row>
</root>
</xsl:template>
</xsl:stylesheet>
my working code, with the original XML file is:
XmlNodeList industrylist = XmlDoc.GetElementsByTagName("row");
foreach (XmlNode Node in industrylist)
{
string industry = Node["var"].Attributes["name"].Value;
_cboIndustryType.Items.Add(new ListItem(industry));
}
With the top XML file my drop down list correctly lists all the names:
- --Select--
- Agriculture
- Airline
I could not set the attribute name as a variable so I changed the code to look for the node innerXML like so:
XmlNodeList industrylist = XmlDoc.GetElementsByTagName("row");
foreach (XmlNode Node in industrylist)
{
string industry = Node.InnerXml;
_cboIndustryType.Items.Add(new ListItem(industry));
}
but after many attempts such as the second XML file I am not able to get the variable to display correctly. I am seeing the following list:
- <xsl:value-of select="aspdnsf:StringResource('industry.cs.1')" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"/>
- Air
- <xsl:value-of select="$pReplacement" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"/>
I would sure appreciate it if someone could tell me what I am doing wrong here.
Thanks in advance!