XML XPath and Simple Stringwriter or Streamwriter Question in Datagrid

Discussion in 'ASP .Net' started by needin4mation@gmail.com, Jun 17, 2005.

  1. Guest

    Hi, please consider this snippet:

    string filename "c:\\inetpub\\wwwroot\\getdirections\\Directions.xml";
    XmlDocument doc = new XmlDocument();
    doc.Load(filename);
    XmlNodeList authorList =
    doc.SelectNodes("/NewDataSet/location[locationidID='westside']");
    StreamWriter writer = new StreamWriter();
    foreach( XmlNode authorNode in authorList )
    {
    writer.Write( authorNode.OuterXml );
    //Response.Write(authorNode.OuterXml);

    }

    DataSet ds = new DataSet();
    ds.ReadXml( writer.ToString() );
    CustomerDataGrid.DataSource = ds.Tables["locations"];
    CustomerDataGrid.DataBind();

    If I use Reponse.Write, this work (not using the datagrid of course).
    What I am trying to do is capture that data in the foreach into some
    kind of stream or *something* so I can bind it to my dataset. The
    query works, the data will return. I just cannot find out how to
    assign it to the dataset from a stream.

    Thank you for any help.
     
    , Jun 17, 2005
    #1
    1. Advertising

  2. intrader Guest

    On Fri, 17 Jun 2005 11:10:15 -0700, needin4mation wrote:

    > Hi, please consider this snippet:
    >
    > string filename "c:\\inetpub\\wwwroot\\getdirections\\Directions.xml";
    > XmlDocument doc = new XmlDocument();
    > doc.Load(filename);
    > XmlNodeList authorList =
    > doc.SelectNodes("/NewDataSet/location[locationidID='westside']");
    > StreamWriter writer = new StreamWriter();
    > foreach( XmlNode authorNode in authorList )
    > {
    > writer.Write( authorNode.OuterXml );
    > //Response.Write(authorNode.OuterXml);
    >
    > }
    >
    > DataSet ds = new DataSet();
    > ds.ReadXml( writer.ToString() );
    > CustomerDataGrid.DataSource = ds.Tables["locations"];
    > CustomerDataGrid.DataBind();
    >
    > If I use Reponse.Write, this work (not using the datagrid of course).
    > What I am trying to do is capture that data in the foreach into some
    > kind of stream or *something* so I can bind it to my dataset. The
    > query works, the data will return. I just cannot find out how to
    > assign it to the dataset from a stream.
    >
    > Thank you for any help.

    Something like
    DataSet ds = new DataSet;
    ds.ReadXml(rawXMLReader);

    Then you can bind
     
    intrader, Jun 17, 2005
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. fabrice
    Replies:
    4
    Views:
    2,342
    fabrice
    Nov 15, 2006
  2. darrel
    Replies:
    3
    Views:
    659
    Cowboy \(Gregory A. Beamer\)
    Mar 27, 2007
  3. Eric

    question about StreamWriter

    Eric, Nov 20, 2008, in forum: ASP .Net
    Replies:
    4
    Views:
    456
  4. Replies:
    6
    Views:
    8,253
    Tom Anderson
    Mar 30, 2009
  5. Tomas Mikula
    Replies:
    3
    Views:
    1,724
    Arne Vajhøj
    Nov 21, 2009
Loading...

Share This Page