Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / XML / May 2004

Tip: Looking for answers? Try searching our database.

string XML transform

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Owen - 28 May 2004 17:46 GMT
Hello:

I have some xml and xsl in string, "not in file". I want to transform the
xml with xsl and the result I want in string (but in xml format). I read
this sample :

public class Sample
{
   private const String filename = "mydata.xml";
   private const String stylesheet = "myStyleSheet.xsl";

   public static void Main()
   {
   XslTransform xslt = new XslTransform();
   xslt.Load(stylesheet);
   XPathDocument xpathdocument = new
   XPathDocument(filename);
   XmlTextWriter writer = new XmlTextWriter(Console.Out);
   writer.Formatting=Formatting.Indented;

   xslt.Transform(xpathdocument, null, writer, null);
   }

And read the class help, but I can found my soluction (maybe I don't so
wise).
Please Help me.

Best regards.
Owen.
Owen - 28 May 2004 23:21 GMT
I found myselft, thanks any way.

 public string TransformXml(string aXml, string aXsl)
 {
  string Result = "";
  XmlDocument xml = new XmlDocument();
  XmlDocument xsl = new XmlDocument();
  xml.LoadXml(aXml);
  xsl.LoadXml(aXsl);

  //creating xslt
  XslTransform xslt = new XslTransform();
  xslt.Load(xsl, null,null) ;

  //creating stringwriter
  StringWriter writer = new System.IO.StringWriter();

  //Transform the xml.
  xslt.Transform(xml, null, writer, null);

  //return string
  Result = writer.ToString();
  writer.Close();

  return Result;
 }

> Hello:
>
[quoted text clipped - 25 lines]
> Best regards.
> Owen.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.