I am trying to retrieve data from XML into XSLT and I am only able to get the record ID value all other nodes appears as static text.... Please review the codes below and share with me what I could possibly be doing wrong. Thanks
XslTransform --- works but only PID data value is carried over to XSLT file
XslCompiledTransform xslt = newXslCompiledTransform();
xslt.Load(xslfilename);
// Transform the file and output an HTML string. string HTMLoutput;
StringWriter writer = newStringWriter();
xslt.Transform(xmlFileName, null, writer);
HTMLoutput = writer.ToString();
XSLT output
<?xmlversion="1.0"encoding="utf-8"?><xsl:stylesheetversion="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"xmlns:msxsl="urn:schemas-microsoft-com:xslt"xmlns:user="urn:user"> <xsl:outputmethod="html"encoding="utf-8"indent="no"/> <xsl:templatematch="IDRoot"> <xsl:textdisable-output-escaping='yes'><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"></xsl:text> <html> <head><title> <xsl:value-ofselect="Subject" /> </title> </head> <bodystyle="font-family:Arial;font-size:12pt;background-color:#EEEEEE"> <h2>Comment </h2> <tablewidth="width: 100%;"cellpadding="0"cellspacing="0"border="1"> <trvalign="top"bgcolor="#9acd32"> <thstyle="width:200px;"></th> <thstyle="width:85%;"></th> </tr> <xsl:for-eachselect="ITBRoot"> <tr> <tdwidth="200"> <divstyle="font-size: 12pt"> <b>Project ID:</b> </div> </td> <td> <xsl:value-ofselect="PID"/> <---DOES show the data value <Output> <xsl:attributename="PID"> <---DOES show the data value <xsl:text> </xsl:text> <xsl:value-ofselect="PID"/> <---DOES show the data value </xsl:attribute> </Output> </td> </tr> <tr> <tdwidth="200"> <divstyle="font-size: 12pt"> <b>Project Name:</b> </div> </td> <td> <xsl:value-ofselect="ProjectName"/> <---does not show the data value <Output> <xsl:attributename="ProjectName"> <---does not show the data value <xsl:text> </xsl:text> <xsl:value-ofselect="ProjectName"/> <---does not show the data value </xsl:attribute> </Output> </td> </tr>
.NET forums are moving to a new home on Microsoft Q&A, we encourage you to go to Microsoft Q&A for .NET for posting new questions and get involved today.
Participant
858 Points
1472 Posts
Problem with xml and Xslt data transfer...help.
Apr 14, 2015 06:44 PM|slimbunny|LINK
I am trying to retrieve data from XML into XSLT and I am only able to get the record ID value all other nodes appears as static text.... Please review the codes below and share with me what I could possibly be doing wrong. Thanks
Xml CODE
XslTransform --- works but only PID data value is carried over to XSLT file
XSLT output
All-Star
45489 Points
7008 Posts
Microsoft
Re: Problem with xml and Xslt data transfer...help.
Apr 15, 2015 06:13 AM|Zhi Lv - MSFT|LINK
Hi slimbunny,
As for this issue, please check the above code, and modify it as below:
XmlElement ProjectNode = doc.CreateElement("ProjectName", "XNamespace.Xmlns=http://www.w3.org/2001/XMLSchema-instance" + " xsi:noNamespaceSchemaLocation=" + "http://localhost:3465/TestSchema.xsd"); oNode = doc.CreateElement("ProjectName"); oNode.InnerText= ProjectName.ToString(CultureInfo.InvariantCulture); ProjectNode.AppendChild(oNode); doc.Save(@"C:\prpject\myxml.xml");
Best Regards,
Dillion