Groups | Blog | Home
all groups > dotnet xml > october 2005 >

dotnet xml : XPath Query into Datagrid


manmit.walia NO[at]SPAM gmail.com
10/12/2005 6:41:58 PM
Hello,
I have a XML File that looks something like this.
<ItemList>
<ProductType>Google</ProductType>
<EmployeeName>John,X,Doe,john.doe@domain.com</EmployeeName>
<EmployeeName>Jane,X,Doe,jane.doe@domain.com</EmployeeName>
<EmployeeName>Larry,X,Doe,larry.doe@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 john.doe@domain.com
Jane X Doe jane.doe@domain.com
Larry X Doe larry.doe@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
Patrick.O.Ige
10/14/2005 12:00:00 AM
Did you get it working?

[quoted text, click to view]

manmit.walia NO[at]SPAM gmail.com
10/14/2005 7:29:42 AM
No....

I get the data but I do not know how to pass it to a datagrid.
AddThis Social Bookmark Button