469,358 Members | 1,596 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,358 developers. It's quick & easy.

Best way to Sort an XmlDocument for display in a datagrid

bep
Hello

What is the best way to sort an XmlDocument for display in a DataGrig?

I can use Xpath with an XpathExpression, and a XpathNavigator. But this
XpathNavigator object is of no use to me, I need a XmlDocument. So is there
an easy way to convert an XPathNavigator object to an XmlDocument?

And I could use a piece of Xstl to transform the doc. But this seems like a
lot of work. I would have to load the Xslt from file, cache it, and apply it.
I also have not found an easy way to transform an XmlDocument in memory. It
seems it is all aimed at taking a disk file, and applying the XSLT from a
file,a nf write to a file.

Thanks for any help.
David
Nov 18 '05 #1
4 2075
for sorting you dont need to use XPathExpression.. its normally used to do a
scan and get nordes that match a certain criteria.
if you want to sort it.
Create a Dataset
Use XmlDataDocument (with relation to the dataset).
Load the XML Document or a part of it (if so load the schema first)
At this step the dataset is populated with the xml data.
now you can apply dataset.tables[0].Select(sortcriteria) to fetch the sorted
order of datarows that can be imported into a table clone and can be
displayed in the datagrid

--

Regards,

Hermit Dave
(http://hdave.blogspot.com)
"be*@10.10.10.10" <be*@10.10.10.10@discussions.microsoft.com> wrote in
message news:C7**********************************@microsof t.com...
Hello

What is the best way to sort an XmlDocument for display in a DataGrig?

I can use Xpath with an XpathExpression, and a XpathNavigator. But this
XpathNavigator object is of no use to me, I need a XmlDocument. So is there an easy way to convert an XPathNavigator object to an XmlDocument?

And I could use a piece of Xstl to transform the doc. But this seems like a lot of work. I would have to load the Xslt from file, cache it, and apply it. I also have not found an easy way to transform an XmlDocument in memory. It seems it is all aimed at taking a disk file, and applying the XSLT from a
file,a nf write to a file.

Thanks for any help.
David

Nov 18 '05 #2
bep
Thanks for your help

How do I get the XmlDataDocument into the Dataset?

Will this work without a schema? We get this data from another system, and
there is no Schema, I would have to create one.

This is also a lot of processing and memory usage. I am surprised XML
sorting is so hard to do...

Thanks again

"Hermit Dave" wrote:
for sorting you dont need to use XPathExpression.. its normally used to do a
scan and get nordes that match a certain criteria.
if you want to sort it.
Create a Dataset
Use XmlDataDocument (with relation to the dataset).
Load the XML Document or a part of it (if so load the schema first)
At this step the dataset is populated with the xml data.
now you can apply dataset.tables[0].Select(sortcriteria) to fetch the sorted
order of datarows that can be imported into a table clone and can be
displayed in the datagrid

--

Regards,

Hermit Dave
(http://hdave.blogspot.com)
"be*@10.10.10.10" <be*@10.10.10.10@discussions.microsoft.com> wrote in
message news:C7**********************************@microsof t.com...
Hello

What is the best way to sort an XmlDocument for display in a DataGrig?

I can use Xpath with an XpathExpression, and a XpathNavigator. But this
XpathNavigator object is of no use to me, I need a XmlDocument. So is

there
an easy way to convert an XPathNavigator object to an XmlDocument?

And I could use a piece of Xstl to transform the doc. But this seems like

a
lot of work. I would have to load the Xslt from file, cache it, and apply

it.
I also have not found an easy way to transform an XmlDocument in memory.

It
seems it is all aimed at taking a disk file, and applying the XSLT from a
file,a nf write to a file.

Thanks for any help.
David


Nov 18 '05 #3
i have just replied to another user with a complete example using xml, xsd
(for more info refer to post - Urgent help needed converting xmlnode to
dataset)

DataSet ds = new DataSet();
ds.ReadXmlSchema(@"..\..\Customers.xsd");

// create matching xml data document
XmlDataDocument xdd = new XmlDataDocument(ds);
try
{
xdd.Load(@"..\..\Customers.xml");
}
catch(Exception ex)
{
MessageBox.Show(ex.Message, "Error Loading XML");
}
this.dgXML.DataSource = ds;
this.dgXML.DataMember = "CustomerData";

hope this helps

--

Regards,

Hermit Dave
(http://hdave.blogspot.com)
"be*@10.10.10.10" <be*********@discussions.microsoft.com> wrote in message
news:90**********************************@microsof t.com...
Thanks for your help

How do I get the XmlDataDocument into the Dataset?

Will this work without a schema? We get this data from another system, and
there is no Schema, I would have to create one.

This is also a lot of processing and memory usage. I am surprised XML
sorting is so hard to do...

Thanks again

"Hermit Dave" wrote:
for sorting you dont need to use XPathExpression.. its normally used to do a scan and get nordes that match a certain criteria.
if you want to sort it.
Create a Dataset
Use XmlDataDocument (with relation to the dataset).
Load the XML Document or a part of it (if so load the schema first)
At this step the dataset is populated with the xml data.
now you can apply dataset.tables[0].Select(sortcriteria) to fetch the sorted order of datarows that can be imported into a table clone and can be
displayed in the datagrid

--

Regards,

Hermit Dave
(http://hdave.blogspot.com)
"be*@10.10.10.10" <be*@10.10.10.10@discussions.microsoft.com> wrote in
message news:C7**********************************@microsof t.com...
Hello

What is the best way to sort an XmlDocument for display in a DataGrig?

I can use Xpath with an XpathExpression, and a XpathNavigator. But this XpathNavigator object is of no use to me, I need a XmlDocument. So is

there
an easy way to convert an XPathNavigator object to an XmlDocument?

And I could use a piece of Xstl to transform the doc. But this seems like
a
lot of work. I would have to load the Xslt from file, cache it, and
apply it.
I also have not found an easy way to transform an XmlDocument in
memory. It
seems it is all aimed at taking a disk file, and applying the XSLT

from a file,a nf write to a file.

Thanks for any help.
David


Nov 18 '05 #4

"be*@10.10.10.10" <be*********@discussions.microsoft.com> wrote in message
news:90**********************************@microsof t.com...
Thanks for your help

How do I get the XmlDataDocument into the Dataset?

Will this work without a schema? We get this data from another system, and
there is no Schema, I would have to create one.
DataSet.InferXMLSchema or just use the Schema designer in Visual Studio.

This is also a lot of processing and memory usage. I am surprised XML
sorting is so hard to do...


Not noticably more than applying a XLST transform.
David
Nov 18 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Martin Clark | last post: by
2 posts views Thread by Fraser | last post: by
4 posts views Thread by Joe | last post: by
19 posts views Thread by Derek Martin | last post: by
4 posts views Thread by G .Net | last post: by
1 post views Thread by CARIGAR | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.