본문 바로가기

Developer

Xml Xslt Transform with C#

C#

/// <summary>
/// Xml, Xslt를 Transform 한 Data를 Return 한다.
/// </summary>
/// <param name="doc">Xml 문서</param>
/// <param name="xsltPath">Xslt 절대경로</param>
/// <returns>Transoform string Data</returns>
#region // string XmlTranseform(XmlDocument doc, string xsltPath) //
public string XmlTranseform(XmlDocument doc, string xsltPath)
{
	XslCompiledTransform xtData = new XslCompiledTransform();
	xtData.Load(xsltPath);

	StringWriter swData = new StringWriter();
	xtData.Transform(doc, null, swData);

	return swData.ToString();
}
#endregion

/// <summary>
/// Xml, Xslt를 Transform 한 Data를 Return 한다.
/// </summary>
/// <param name="strXml">Xml String Data</param>
/// <param name="xsltPath">Xslt 절대경로</param>
/// <returns>Transoform string Data</returns>
#region // string XmlTranseform(string strXml, string xsltPath) //
public string XmlTranseform(string strXml, string xsltPath)
{
	XmlDocument doc = new XmlDocument();
	doc.LoadXml(strXml);

	XslCompiledTransform xtData = new XslCompiledTransform();
	xtData.Load(xsltPath);

	StringWriter swData = new StringWriter();
	xtData.Transform(doc, null, swData);

	return swData.ToString();
}
#endregion

'Developer' 카테고리의 다른 글

Create Table  (0) 2009.01.28
HTML Mailto Protocol  (0) 2009.01.21
Xml Xslt Transform with Javascript  (0) 2009.01.13
Javascript XmlDocument handler  (0) 2009.01.07
showModalDialog, showModelessDialog 사용방법  (0) 2009.01.02