473,408 Members | 1,772 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

XML XPath and Simple Stringwriter or Streamwriter Question in Datagrid

Hi, please consider this snippet:

string filename "c:\\inetpub\\wwwroot\\getdirections\\Directions.x ml";
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.

Nov 19 '05 #1
1 1276
On Fri, 17 Jun 2005 11:10:15 -0700, needin4mation wrote:
Hi, please consider this snippet:

string filename "c:\\inetpub\\wwwroot\\getdirections\\Directions.x ml";
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

Nov 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: bdinmstig | last post by:
I refined my attempt a little further, and the following code does seem to work, however it has 2 major problems: 1. Very limited support for XPath features Basic paths are supported for...
9
by: JJ | last post by:
Hi All, I noticed that XmlNode and XpathNavigator are quite similiar. XmlNode seems to navigate over an XML Doc and so does XPathNav so when do I use XPathNavigator instead of XmlNode? ...
7
by: Ot | last post by:
I posted this to the wrong group. It went to m.p.dotnet.languages.vb. Ooops. -------------------------------------------------------------------- I have this tiny problem. I have learned...
8
by: Lawrence Oluyede | last post by:
Is there a way to treat html tags like simple text? I explain myself, if I have a bunch of xml like <content type="application/xhtml+xml" xml:base="http://loluyede.blogspot.com" xml:lang="en-US"...
1
by: Chucker | last post by:
I would like to select some nodes from a very large XML document and then apply a stylesheet to the dom fragment / nodelist that is the result of my XPath-Query. It seems to me now that I have...
2
by: Pawel | last post by:
I have small problem with XslTransformation. I get from WebService xml document. I have xslt and I want transform xml document to html code. It's look easy but I cant't manage with xPath. Maybe...
6
by: kinekine | last post by:
Hello, i have a big problem with my email component, because each time i write the generated message directly to the spooler, the streamwriter will write in Unicode. The file starts with a FF...
3
by: darrel | last post by:
I'm creating an RSS feed based off of this tutorial: http://www.uberasp.net/ArticlePrint.aspx?id=17 In a nutshell, they are doing: Response.Clear() Response.ContentType = "text/xml"...
0
by: Arch Stanton | last post by:
I'm writing the contents of my datagrid to an Excel spreadsheet using the following code: Sub WriteToExcel(Sender as Object, E as EventArgs) 'Export the contents of the current datagrid to Excel...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.