DataSet into XmlReader

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

    DataSet into XmlReader

    Folks, I'd like to write out a DataSet's Xml into an XmlReader? How do I do
    that?
    Thanks!


  • Kevin Spencer

    #2
    Re: DataSet into XmlReader

    My head hurts from trying to figure how how one could write to a reader...

    Happy New Year, everyone!

    --
    HTH,
    Kevin Spencer
    ..Net Developer
    Microsoft MVP
    Big things are made up
    of lots of little things.

    "George Durzi" <gdurzi@hotmail .com> wrote in message
    news:eUAXdR8zDH A.1688@TK2MSFTN GP10.phx.gbl...[color=blue]
    > Folks, I'd like to write out a DataSet's Xml into an XmlReader? How do I[/color]
    do[color=blue]
    > that?
    > Thanks!
    >
    >[/color]


    Comment

    • George Durzi

      #3
      Re: DataSet into XmlReader

      I guess I used some wrong terminology. I guess if the reader is "reading",
      something is writing to it ... hahah

      DataSet oDataSet = Some Report Data
      XmlTextReader oXmlTextReader = new XmlTextReader(o DataSet.GetXml( ),
      XmlNodeType.Doc ument, null);


      "Kevin Spencer" <kevin@takempis .com> wrote in message
      news:ewWnrY8zDH A.1364@TK2MSFTN GP10.phx.gbl...[color=blue]
      > My head hurts from trying to figure how how one could write to a reader...
      >
      > Happy New Year, everyone!
      >
      > --
      > HTH,
      > Kevin Spencer
      > .Net Developer
      > Microsoft MVP
      > Big things are made up
      > of lots of little things.
      >
      > "George Durzi" <gdurzi@hotmail .com> wrote in message
      > news:eUAXdR8zDH A.1688@TK2MSFTN GP10.phx.gbl...[color=green]
      > > Folks, I'd like to write out a DataSet's Xml into an XmlReader? How do I[/color]
      > do[color=green]
      > > that?
      > > Thanks!
      > >
      > >[/color]
      >
      >[/color]


      Comment

      • Patrick Steele [MVP]

        #4
        Re: DataSet into XmlReader

        In article <eUAXdR8zDHA.16 88@TK2MSFTNGP10 .phx.gbl>, gdurzi@hotmail. com
        says...[color=blue]
        > Folks, I'd like to write out a DataSet's Xml into an XmlReader? How do I do
        > that?[/color]

        Why do you need to do this? DataSet.WriteXm l can convert the DataSet
        into an XML format and then the Reader can read the XML. But if you
        just want the data from the DataSet, why serialize it to XML?

        --
        Patrick Steele
        Microsoft .NET MVP

        Comment

        • George Durzi

          #5
          Re: DataSet into XmlReader

          Here's the background ... When I was passing an XmlDataDocument to an
          XslTransform, I was getting HORRIBLE performance.

          Someone no the Xsl newsgroups suggested I pass an XPathDocument instead. The
          XPathDocument constructor that made most sense was the one that took an
          XmlReader in.

          I got an incredible performance improvement when using the XPathDocument as
          opposed to the XmlDataDocument ... All I needed was to figure out how to get
          the Xml into an XmlTextReader, then cast it to an XmlReader, and use it to
          create the XPathDocument

          DataSet oDataSet = populate dataset with some report data
          XmlTextReader oXmlTextReader = new XmlTextReader(o DataSet.GetXml( ),
          XmlNodeType.Doc ument, null);
          System.IO.FileS tream oFileStream = new System.IO.FileS tream(exportPat h,
          System.IO.FileM ode.Create);
          System.Xml.XmlT extWriter oXmlTextWriter = new
          System.Xml.XmlT extWriter(oFile Stream, System.Text.Enc oding.Unicode);
          try
          {
          XmlUrlResolver oXmlUrlResolver = new XmlUrlResolver( );
          oXmlUrlResolver .Credentials = CredentialCache .DefaultCredent ials;
          System.Xml.Xsl. XslTransform oXslTransform = new
          System.Xml.Xsl. XslTransform();
          oXslTransform.L oad(_XslPath, oXmlUrlResolver );
          XPathDocument oXPathDocument = new XPathDocument(o XmlReader);
          oXslTransform.T ransform(oXPath Document, null, oXmlTextWriter,
          oXmlUrlResolver );
          oXmlTextWriter. Close();

          return exportPath; // path of exported file
          }
          catch (Exception ex)
          {
          oXmlTextWriter. Close();
          System.IO.File. Delete(exportPa th);
          throw(ex);
          }




          "Patrick Steele [MVP]" <patrick@mvps.o rg> wrote in message
          news:MPG.1a5cd9 124d9c694b98984 6@msnews.micros oft.com...[color=blue]
          > In article <eUAXdR8zDHA.16 88@TK2MSFTNGP10 .phx.gbl>, gdurzi@hotmail. com
          > says...[color=green]
          > > Folks, I'd like to write out a DataSet's Xml into an XmlReader? How do I[/color][/color]
          do[color=blue][color=green]
          > > that?[/color]
          >
          > Why do you need to do this? DataSet.WriteXm l can convert the DataSet
          > into an XML format and then the Reader can read the XML. But if you
          > just want the data from the DataSet, why serialize it to XML?
          >
          > --
          > Patrick Steele
          > Microsoft .NET MVP
          > http://weblogs.asp.net/psteele[/color]


          Comment

          • Patrick Steele [MVP]

            #6
            Re: DataSet into XmlReader

            In article <esWTVk8zDHA.32 24@tk2msftngp13 .phx.gbl>, gdurzi@hotmail. com
            says...[color=blue]
            > All I needed was to figure out how to get
            > the Xml into an XmlTextReader, then cast it to an XmlReader, and use it to
            > create the XPathDocument[/color]

            An XmlTextReader is an XmlReader, so no casting should be necessary.

            --
            Patrick Steele
            Microsoft .NET MVP

            Comment

            Working...