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. XML / XSL
  4. Writing XML stored in a string using Respose.Write

Writing XML stored in a string using Respose.Write

Scheduled Pinned Locked Moved XML / XSL
htmlxmlhelptutorial
8 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.
  • A Offline
    A Offline
    anufabian
    wrote on last edited by
    #1

    I have some XML tags stored in a string. This data is obtained through remoting. I want the same to be displayed on an HTML page by using a Respose.Write. When I do a Response.write of the string then it loses its XML format and just displays as string alone. Could I know how to display the same in XML format itself. I tried using REsponse.ContenType = "text/xml", But this is giving me an error

    S 1 Reply Last reply
    0
    • A anufabian

      I have some XML tags stored in a string. This data is obtained through remoting. I want the same to be displayed on an HTML page by using a Respose.Write. When I do a Response.write of the string then it loses its XML format and just displays as string alone. Could I know how to display the same in XML format itself. I tried using REsponse.ContenType = "text/xml", But this is giving me an error

      S Offline
      S Offline
      Stefan Troschuetz
      wrote on last edited by
      #2

      anufabian wrote:

      But this is giving me an error

      What error?


      "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook

      www.troschuetz.de

      A 1 Reply Last reply
      0
      • S Stefan Troschuetz

        anufabian wrote:

        But this is giving me an error

        What error?


        "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook

        www.troschuetz.de

        A Offline
        A Offline
        anufabian
        wrote on last edited by
        #3

        It gives me the following error :::: The XML page cannot be displayed Cannot view XML input using XSL style sheet. Please correct the error and then click the Refresh button, or try again later. -------------------------------------------------------------------------------- Cannot have a DOCTYPE declaration outside of a prolog. Error processing resource 'http://localhost/WebApplication10/WebForm... ----------^

        S 1 Reply Last reply
        0
        • A anufabian

          It gives me the following error :::: The XML page cannot be displayed Cannot view XML input using XSL style sheet. Please correct the error and then click the Refresh button, or try again later. -------------------------------------------------------------------------------- Cannot have a DOCTYPE declaration outside of a prolog. Error processing resource 'http://localhost/WebApplication10/WebForm... ----------^

          S Offline
          S Offline
          Stefan Troschuetz
          wrote on last edited by
          #4

          Try calling the Clear method before writing the XML string to make sure the HTTP response contains nothing else.

          Response.ContenType = "text/xml";
          Response.Clear();
          Response.Write(xmlString);


          "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook

          www.troschuetz.de

          A 1 Reply Last reply
          0
          • S Stefan Troschuetz

            Try calling the Clear method before writing the XML string to make sure the HTTP response contains nothing else.

            Response.ContenType = "text/xml";
            Response.Clear();
            Response.Write(xmlString);


            "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook

            www.troschuetz.de

            A Offline
            A Offline
            anufabian
            wrote on last edited by
            #5

            I am still getting the same error. The XML page cannot be displayed Cannot view XML input using XSL style sheet. Please correct the error and then click the Refresh button, or try again later. -------------------------------------------------------------------------------- Cannot have a DOCTYPE declaration outside of a prolog. Error processing resource 'http://localhost/WebApplication10/WebForm... ----------^ I assume that the line DOCTYPE HTML... is the firsy line written on an aspx page . Is this causing the problem. I tried to save the xml in a file , it works fine. However my requirement is to display the XML on an aspx page , along with the look and feel of XML .

            S 1 Reply Last reply
            0
            • A anufabian

              I am still getting the same error. The XML page cannot be displayed Cannot view XML input using XSL style sheet. Please correct the error and then click the Refresh button, or try again later. -------------------------------------------------------------------------------- Cannot have a DOCTYPE declaration outside of a prolog. Error processing resource 'http://localhost/WebApplication10/WebForm... ----------^ I assume that the line DOCTYPE HTML... is the firsy line written on an aspx page . Is this causing the problem. I tried to save the xml in a file , it works fine. However my requirement is to display the XML on an aspx page , along with the look and feel of XML .

              S Offline
              S Offline
              Stefan Troschuetz
              wrote on last edited by
              #6

              anufabian wrote:

              However my requirement is to display the XML on an aspx page

              Ah, I thought you want to send back the pure XML. My fault. Take a look at the System.Web.UI.WebControls.Xml control and the continuative links in its documentation. I think they should help you to achieve what you want.


              "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook

              www.troschuetz.de

              A 1 Reply Last reply
              0
              • S Stefan Troschuetz

                anufabian wrote:

                However my requirement is to display the XML on an aspx page

                Ah, I thought you want to send back the pure XML. My fault. Take a look at the System.Web.UI.WebControls.Xml control and the continuative links in its documentation. I think they should help you to achieve what you want.


                "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook

                www.troschuetz.de

                A Offline
                A Offline
                anufabian
                wrote on last edited by
                #7

                The above technique did not help me. However I was able to solve the issue by using something like this. Response.Write("" + outputstring + "/xmp>"); This i got it from some one else. However I still dont understand what is the use of <xmp> tag. If possible could you throw some light on this. </x-turndown>

                S 1 Reply Last reply
                0
                • A anufabian

                  The above technique did not help me. However I was able to solve the issue by using something like this. Response.Write("" + outputstring + "/xmp>"); This i got it from some one else. However I still dont understand what is the use of <xmp> tag. If possible could you throw some light on this. </x-turndown>

                  S Offline
                  S Offline
                  Stefan Troschuetz
                  wrote on last edited by
                  #8

                  "The XMP tag displays a sequence of literal characters in the browser's default fixed-width font. The XMP element displays all white space and line breaks exactly as they appear inside the and tags." (HTML Tag Reference[^]) Another resource (SelfHTML[^]) said that the xmp tag is no longer a part of the HTML standard. Though they are still supported by current browsers, one should not count on this. The resource suggests of instead using the pre tag. Since the pre element interprets HTML tags, you must use special symbols for any character that has a meaning in HTML that you wish to be displayed rather than interpreted. For example, use &< for the < symbol, and use &> for the > symbol.


                  "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook

                  www.troschuetz.de

                  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