Convert an xml document to a string or stringbuilder?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Steve

    Convert an xml document to a string or stringbuilder?

    Hello. I am relatively new to using XML, but I'm trying to convert an xml
    document directly to a string or stringbuilder. I'm trying to use the
    XmlDocument class and Stringwriter classes, but I am unsucessful. What am I
    missing? Thank you for your help in advance!

    --
    Steve
  • Kevin Yu [MSFT]

    #2
    RE: Convert an xml document to a string or stringbuilder?

    Hi Steve,

    First of all, I would like to confirm my understanding of your issue. From
    your description, I understand that you need to get the whole xml document
    as a string to a string object. If there is any misunderstandin g, please
    feel free to let me know.

    In this case, we can use XmlDocument.Out erXml to get the whole document as
    a string. Here's an example:

    XmlDocument doc = new XmlDocument();
    doc.Load(@"c:\a .xml");
    this.textBox1.T ext = doc.OuterXml;

    HTH.

    Kevin Yu
    =======
    "This posting is provided "AS IS" with no warranties, and confers no
    rights."

    Comment

    • Steve

      #3
      RE: Convert an xml document to a string or stringbuilder?

      Thanks Kevin. That's what I'm looking for, however, I am using the 2.0
      framework. The OuterXML has moved somewhere else. Any ideas where? Thank
      you!

      "Kevin Yu [MSFT]" wrote:
      [color=blue]
      > Hi Steve,
      >
      > First of all, I would like to confirm my understanding of your issue. From
      > your description, I understand that you need to get the whole xml document
      > as a string to a string object. If there is any misunderstandin g, please
      > feel free to let me know.
      >
      > In this case, we can use XmlDocument.Out erXml to get the whole document as
      > a string. Here's an example:
      >
      > XmlDocument doc = new XmlDocument();
      > doc.Load(@"c:\a .xml");
      > this.textBox1.T ext = doc.OuterXml;
      >
      > HTH.
      >
      > Kevin Yu
      > =======
      > "This posting is provided "AS IS" with no warranties, and confers no
      > rights."
      >
      >[/color]

      Comment

      • Kevin Yu [MSFT]

        #4
        RE: Convert an xml document to a string or stringbuilder?

        Hi Steve,

        I checked it on my computer, the OuterXml property still exists in
        XmlDocument class in .net framework 2.0. Since .NET framework is backward
        compatible, I don't think it will be moved to anywhere else. I'm currently
        using Visual Studio .NET 2005 beta1.

        If anything is unclear, please feel free to reply to this post.

        Kevin Yu
        =======
        "This posting is provided "AS IS" with no warranties, and confers no
        rights."

        Comment

        Working...