471,313 Members | 1,892 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

Help on Filtering XML nodes ???

Dear all,

I have a csv file data which has been read and populate on a dataset object.
then I need to bind part of the content of the dataset to a treeview control.
I have read that XML format is particular usefull to be bind to a treeview
as it handle nodes. So I have try to save my dataset content into a xml file.
The content of that file is as follow :

- <NewDataSet>
- <REC_INFO>
<FILE_NAME>REC00001.CSV</FILE_NAME>
<RECIPE_CLASS>Pipe</RECIPE_CLASS>
<RECIPE_NAME>25 x 2.5 mm</RECIPE_NAME>
<LINE_NAME>LP602</LINE_NAME>
<GROUPE_NAME>LP602</GROUPE_NAME>
<MODIFIED>02/11/2004 15:15:04</MODIFIED>
</REC_INFO>
- <REC_INFO>
<FILE_NAME>REC00002.CSV</FILE_NAME>
<RECIPE_CLASS>Profile</RECIPE_CLASS>
<RECIPE_NAME>Coling</RECIPE_NAME>
<LINE_NAME>LP602</LINE_NAME>
<GROUPE_NAME>LP602</GROUPE_NAME>
<MODIFIED>02/11/2004 15:15:04</MODIFIED>
</REC_INFO>

Then I have founc a sample function that bind xmlnodes to treeview node but
then in my case it displays all of them. I am only interesting to display ina
treeview the XML node named RECIPE_CLASS

I have seen that for filtering nodes we need to us Xpath but how to define
my filter then
How can I do that ?

Thanks for your help
regards
serge
Jul 21 '05 #1
3 2039
The XPath expression is:
/REC_INFO/RECIPE_CLASS

"serge calderara" <se************@discussions.microsoft.com> wrote in
message news:C5**********************************@microsof t.com...
Dear all,

I have a csv file data which has been read and populate on a dataset
object.
then I need to bind part of the content of the dataset to a treeview
control.
I have read that XML format is particular usefull to be bind to a treeview
as it handle nodes. So I have try to save my dataset content into a xml
file.
The content of that file is as follow :

- <NewDataSet>
- <REC_INFO>
<FILE_NAME>REC00001.CSV</FILE_NAME>
<RECIPE_CLASS>Pipe</RECIPE_CLASS>
<RECIPE_NAME>25 x 2.5 mm</RECIPE_NAME>
<LINE_NAME>LP602</LINE_NAME>
<GROUPE_NAME>LP602</GROUPE_NAME>
<MODIFIED>02/11/2004 15:15:04</MODIFIED>
</REC_INFO>
- <REC_INFO>
<FILE_NAME>REC00002.CSV</FILE_NAME>
<RECIPE_CLASS>Profile</RECIPE_CLASS>
<RECIPE_NAME>Coling</RECIPE_NAME>
<LINE_NAME>LP602</LINE_NAME>
<GROUPE_NAME>LP602</GROUPE_NAME>
<MODIFIED>02/11/2004 15:15:04</MODIFIED>
</REC_INFO>

Then I have founc a sample function that bind xmlnodes to treeview node
but
then in my case it displays all of them. I am only interesting to display
ina
treeview the XML node named RECIPE_CLASS

I have seen that for filtering nodes we need to us Xpath but how to define
my filter then
How can I do that ?

Thanks for your help
regards
serge

Jul 21 '05 #2
Thnaks for the info , I will give a try..

by the way if I apply my XPath string as you said /RECE_INFO/RECIPE_CLASSE
I should retrieve only those node right?

Ok then I add my first node in my treeview collection. Then things that
might happen is that I could have more that one RECIPE_CLASS node value. , so
I can I verify if my node is already existing in treenode collection in order
to ad it or not ?

I have try to use the Contains(myNode) function but it always return false
even if the node ahas really be added.

Any suggestion ?

thnaks for your help
serge

"Sean Hederman" wrote:
The XPath expression is:
/REC_INFO/RECIPE_CLASS

"serge calderara" <se************@discussions.microsoft.com> wrote in
message news:C5**********************************@microsof t.com...
Dear all,

I have a csv file data which has been read and populate on a dataset
object.
then I need to bind part of the content of the dataset to a treeview
control.
I have read that XML format is particular usefull to be bind to a treeview
as it handle nodes. So I have try to save my dataset content into a xml
file.
The content of that file is as follow :

- <NewDataSet>
- <REC_INFO>
<FILE_NAME>REC00001.CSV</FILE_NAME>
<RECIPE_CLASS>Pipe</RECIPE_CLASS>
<RECIPE_NAME>25 x 2.5 mm</RECIPE_NAME>
<LINE_NAME>LP602</LINE_NAME>
<GROUPE_NAME>LP602</GROUPE_NAME>
<MODIFIED>02/11/2004 15:15:04</MODIFIED>
</REC_INFO>
- <REC_INFO>
<FILE_NAME>REC00002.CSV</FILE_NAME>
<RECIPE_CLASS>Profile</RECIPE_CLASS>
<RECIPE_NAME>Coling</RECIPE_NAME>
<LINE_NAME>LP602</LINE_NAME>
<GROUPE_NAME>LP602</GROUPE_NAME>
<MODIFIED>02/11/2004 15:15:04</MODIFIED>
</REC_INFO>

Then I have founc a sample function that bind xmlnodes to treeview node
but
then in my case it displays all of them. I am only interesting to display
ina
treeview the XML node named RECIPE_CLASS

I have seen that for filtering nodes we need to us Xpath but how to define
my filter then
How can I do that ?

Thanks for your help
regards
serge


Jul 21 '05 #3
"serge calderara" <se************@discussions.microsoft.com> wrote in
message news:C0**********************************@microsof t.com...
Thnaks for the info , I will give a try..

by the way if I apply my XPath string as you said /RECE_INFO/RECIPE_CLASSE
I should retrieve only those node right?
Yes.
Ok then I add my first node in my treeview collection. Then things that
might happen is that I could have more that one RECIPE_CLASS node value. ,
so
I can I verify if my node is already existing in treenode collection in
order
to ad it or not ?

I have try to use the Contains(myNode) function but it always return false
even if the node ahas really be added.
What's probably happenning is like the following:
TreeNode firstNode = new TreeNode("Hello");
myTree.Nodes.Add(firstNode);
TreeNode secondNode = new TreeNode("Hello");
bool exists = myTree.Nodes.Contains(secondNode));

The variable exists will always be false, since we are dealing with two
different TreeNode objects. They may have the same text, but the objects are
not the same. You could just iterate the tree view to see if any nodes at
that level have the specified text. If it's a large number of nodes, some
kind of hashed collection would probably be ideal. Alternatively

//RECE_INFO/RECIPE_CLASSE[not(.=preceding::RECIPE_CLASSE)]

But this would imply that the XML is sorted by RECIPE_CLASSE. You can do
this by using XPathExpression and adding RECIPE_CLASSE to AddSort.
Any suggestion ?

thnaks for your help
serge

"Sean Hederman" wrote:
The XPath expression is:
/REC_INFO/RECIPE_CLASS

"serge calderara" <se************@discussions.microsoft.com> wrote in
message news:C5**********************************@microsof t.com...
> Dear all,
>
> I have a csv file data which has been read and populate on a dataset
> object.
> then I need to bind part of the content of the dataset to a treeview
> control.
> I have read that XML format is particular usefull to be bind to a
> treeview
> as it handle nodes. So I have try to save my dataset content into a xml
> file.
> The content of that file is as follow :
>
> - <NewDataSet>
> - <REC_INFO>
> <FILE_NAME>REC00001.CSV</FILE_NAME>
> <RECIPE_CLASS>Pipe</RECIPE_CLASS>
> <RECIPE_NAME>25 x 2.5 mm</RECIPE_NAME>
> <LINE_NAME>LP602</LINE_NAME>
> <GROUPE_NAME>LP602</GROUPE_NAME>
> <MODIFIED>02/11/2004 15:15:04</MODIFIED>
> </REC_INFO>
> - <REC_INFO>
> <FILE_NAME>REC00002.CSV</FILE_NAME>
> <RECIPE_CLASS>Profile</RECIPE_CLASS>
> <RECIPE_NAME>Coling</RECIPE_NAME>
> <LINE_NAME>LP602</LINE_NAME>
> <GROUPE_NAME>LP602</GROUPE_NAME>
> <MODIFIED>02/11/2004 15:15:04</MODIFIED>
> </REC_INFO>
>
> Then I have founc a sample function that bind xmlnodes to treeview node
> but
> then in my case it displays all of them. I am only interesting to
> display
> ina
> treeview the XML node named RECIPE_CLASS
>
> I have seen that for filtering nodes we need to us Xpath but how to
> define
> my filter then
> How can I do that ?
>
> Thanks for your help
> regards
> serge


Jul 21 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by csx | last post: by
3 posts views Thread by serge calderara | last post: by
1 post views Thread by Sisnaz | last post: by
1 post views Thread by sp | last post: by
2 posts views Thread by JUAN ERNESTO FLORES BELTRAN | last post: by
9 posts views Thread by =?Utf-8?B?YWJjZA==?= | last post: by
reply views Thread by =?Utf-8?B?QnJpYW4gTmljaG9sc29u?= | last post: by

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.