Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. XmlTransformation output to string

XmlTransformation output to string

Scheduled Pinned Locked Moved C#
xmlquestion
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    tomiga
    wrote on last edited by
    #1

    I have to use xml transformation. The simplest way is XslTransform xsltransform = new XslTransform(); xsltransform.Load("favorite.xsl"); xsltransform.Transform("MyDocument.xml", "TransformResult.xml"); But it is necessery for me to put output of transformation not to file but to string... (all of overloaded members of Transform has file or stream) Do you have any idea?

    J 1 Reply Last reply
    0
    • T tomiga

      I have to use xml transformation. The simplest way is XslTransform xsltransform = new XslTransform(); xsltransform.Load("favorite.xsl"); xsltransform.Transform("MyDocument.xml", "TransformResult.xml"); But it is necessery for me to put output of transformation not to file but to string... (all of overloaded members of Transform has file or stream) Do you have any idea?

      J Offline
      J Offline
      James T Johnson
      wrote on last edited by
      #2

      tomiga wrote: (all of overloaded members of Transform has file or stream) You could create a memory stream to house the output of the transformation; then once the transformation is done convert the underlying byte array to a string. System.Text.(Encoding).GetString(myByteArray) if the XML file uses ASCII then (Encoding) should be ASCIIEncoding; if it uses UTF8 then it should be UTF8Encoding; etc... James "Java is free - and worth every penny." - Christian Graus

      T 1 Reply Last reply
      0
      • J James T Johnson

        tomiga wrote: (all of overloaded members of Transform has file or stream) You could create a memory stream to house the output of the transformation; then once the transformation is done convert the underlying byte array to a string. System.Text.(Encoding).GetString(myByteArray) if the XML file uses ASCII then (Encoding) should be ASCIIEncoding; if it uses UTF8 then it should be UTF8Encoding; etc... James "Java is free - and worth every penny." - Christian Graus

        T Offline
        T Offline
        tomiga
        wrote on last edited by
        #3

        Thx. I have found stream witch writes output to string. StringWriter class. It helps me to solve problem.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups