XML XPath and Simple Stringwriter or Streamwriter Question in Datagrid

N

needin4mation

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.
 
I

intrader

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top