473,468 Members | 1,351 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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 2173
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Martin Clark | last post by:
Hi, I have a C# Windows .net application (not asp.net) which uses a datagrid to display information. The datagrid is populated from a DataView, in which I specify a sort order ("ORDER BY...
4
by: Bruce Pullum | last post by:
I have a datagrid that I am using a DataView with. All works great for the sorting of the columns. However, after I sort the column, and then try and select a data row to edit, the row selected...
0
by: Patrick | last post by:
I'm working on a contact management application, and need a hand with one aspect... Here's what I want to create: ------------------------------------ A form split into two parts. There is a...
2
by: Fraser | last post by:
Hi, I'm needing to update an xml file by inserting a new node. First I need to load the xml into a XmlDocument from file. In the first run, the file won't exist and I will have to create a...
3
by: Stan | last post by:
I am looking for the best solution for this scenario: ASP.NET needs display an editable form with 20 textboxes. Data source is xml. Xml must be updated. if user clicks Update button on the form....
4
by: Joe | last post by:
Hello, I have a datagrid in an nested html table (one table inside of another table) and have set the allowsSorting property to true. I've created in the code-behind a method (Sub - I'm using...
19
by: Derek Martin | last post by:
Hi there, I have been playing with sorting my arraylist and having some troubles. Maybe just going about it wrong. My arraylist contains objects and one of the members of the object is 'name.' I...
4
by: Dave | last post by:
(My apologies for posting this on two forums. I have just found out the other one was the incorrect location) I am writing a VB.NET 2003 web application to operate on my company's intranet. It...
4
by: G .Net | last post by:
Hi I have a question which I hope you can help with. I am setting the DataSource of a DataGrid to be a DataView. I am sorting the DataView by various fields which include a Date. When I...
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
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,...
1
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
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...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.