473,385 Members | 2,243 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,385 software developers and data experts.

XPath Query into Datagrid

Hello,
I have a XML File that looks something like this.
<ItemList>
<ProductType>Google</ProductType>
<EmployeeName>John,X,Doe,jo******@domain.com</EmployeeName>
<EmployeeName>Jane,X,Doe,ja******@domain.com</EmployeeName>
<EmployeeName>Larry,X,Doe,la*******@domain.com</EmployeeName>
</ItemList>

What I am trying to accomplish is do an XPath Query that finds all
employees where the ProductType is swTitle.Text(Product Name that a
user enters into a form). But I want to display the result into a
datagrid with 4 columns ( FN, MI, LN, EMAIL ) so for example:

If some enters 'Google' the result will be the following style:

First Name MI Last Name Email
John X Doe jo******@domain.com
Jane X Doe ja******@domain.com
Larry X Doe la*******@domain.com

Here is the code that I am using:

void GetUserList()
{

XmlDocument doc = new XmlDocument();
doc.Load(Server.MapPath("software.xml"));

//XmlNode sw;
XmlNodeList sw;
XmlNode root = doc.DocumentElement;

// SEARCH XML FILE
string t = "'" + swTitle.Text + "'";
sw=root.SelectNodes("//EMPProductType[ProductType=" + t + "
]/EmployeeName");
int total = sw.Count;
// RETURN DATA FROM XPATH
if(sw != null)
{
for (int i=0; i < total; i++)
{

temp = temp + "<br> " + sw[i].OuterXml;
}

test.Text = temp;
usedCount.Text = total.ToString();

}
Any Help would be gratefull

Nov 12 '05 #1
2 1339
Did you get it working?

<ma**********@gmail.com> wrote in message
news:11*********************@g47g2000cwa.googlegro ups.com...
Hello,
I have a XML File that looks something like this.
<ItemList>
<ProductType>Google</ProductType>
<EmployeeName>John,X,Doe,jo******@domain.com</EmployeeName>
<EmployeeName>Jane,X,Doe,ja******@domain.com</EmployeeName>
<EmployeeName>Larry,X,Doe,la*******@domain.com</EmployeeName>
</ItemList>

What I am trying to accomplish is do an XPath Query that finds all
employees where the ProductType is swTitle.Text(Product Name that a
user enters into a form). But I want to display the result into a
datagrid with 4 columns ( FN, MI, LN, EMAIL ) so for example:

If some enters 'Google' the result will be the following style:

First Name MI Last Name Email
John X Doe jo******@domain.com
Jane X Doe ja******@domain.com
Larry X Doe la*******@domain.com

Here is the code that I am using:

void GetUserList()
{

XmlDocument doc = new XmlDocument();
doc.Load(Server.MapPath("software.xml"));

//XmlNode sw;
XmlNodeList sw;
XmlNode root = doc.DocumentElement;

// SEARCH XML FILE
string t = "'" + swTitle.Text + "'";
sw=root.SelectNodes("//EMPProductType[ProductType=" + t + "
]/EmployeeName");
int total = sw.Count;
// RETURN DATA FROM XPATH
if(sw != null)
{
for (int i=0; i < total; i++)
{

temp = temp + "<br> " + sw[i].OuterXml;
}

test.Text = temp;
usedCount.Text = total.ToString();

}
Any Help would be gratefull

Nov 12 '05 #2
No....

I get the data but I do not know how to pass it to a datagrid.

Nov 12 '05 #3

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

Similar topics

6
by: 0wl | last post by:
Hi, I am trying to get the value of child from xmlstr = """<p:root xmlns:p="http://tempuri.org/string"><p:child DataType="String">Hellpppp</p:child></p:root>""" using...
8
by: Terry P | last post by:
Are there any tools (java classes, tag libraries) which can translate xpath statements into a SQL query? Given an xpath query which has a predicate that filters node values or attributes, I want...
3
by: gfrommer | last post by:
Hello Everyone, I'm writing a server in java, and I want the clients to pass me an XPath query. I want the XPath queries to be in a specific format though, I'm pretty sure it's valid but I want...
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...
10
by: Michael C# | last post by:
OK, here's the deal. I have a small XML file that represents a small database table. I load it into a System.XML.XMLDocument. So far so good. I run an XPath query against it to retrieve all the...
5
by: Gnic | last post by:
Hi , I have an XmlDocument instance, I want to find a node in the xml, but I don't know it's path until runtime, for example <aaa> <bbb name="x"/> <aaa attr="y"> <ccc>sometext</ccc> </aaa>
6
by: dotnetnoob | last post by:
i would like to know how i can build xpath expression dynamiclly. let's say i have a following xml file: <EventEnrollment InstanceNumber = "675"> <EventSource> <ObjectReference...
3
by: Jason Mobarak | last post by:
Hello -- I'm attempting to get a handle on how to do xpath queries with System.Xml -- so far the biggest hurdle has been how to deal with a default namespace. If I use the test xml: <?xml...
2
by: =?Utf-8?B?RGlmZmlkZW50?= | last post by:
Hello All, I am trying to construct an XPath query against an XML document, for a requirement that I have. Below is the XML fragment: <SUBMISSIONS> <SUBMISSION YEAR="2004"> <MONTH...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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...

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.