473,657 Members | 2,270 Online
Bytes | Software Development & Data Engineering Community
+ 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 2183
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(sortcri teria) 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.1 0" <be*@10.10.10.1 0@discussions.m icrosoft.com> wrote in
message news:C7******** *************** ***********@mic rosoft.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(sortcri teria) 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.1 0" <be*@10.10.10.1 0@discussions.m icrosoft.com> wrote in
message news:C7******** *************** ***********@mic rosoft.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.ReadXmlSchem a(@"..\..\Custo mers.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.Data Source = ds;
this.dgXML.Data Member = "CustomerDa ta";

hope this helps

--

Regards,

Hermit Dave
(http://hdave.blogspot.com)
"be*@10.10.10.1 0" <be*********@di scussions.micro soft.com> wrote in message
news:90******** *************** ***********@mic rosoft.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(sortcri teria) 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.1 0" <be*@10.10.10.1 0@discussions.m icrosoft.com> wrote in
message news:C7******** *************** ***********@mic rosoft.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.1 0" <be*********@di scussions.micro soft.com> wrote in message
news:90******** *************** ***********@mic rosoft.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.InferXM LSchema 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
1495
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 CreateDate DESC"). The user of the application is able to then resort the data by clicking on any of the datagrid column headings. What I can't work out how to do, is to detect what new sort order the user might have selected, i.e. what the
4
2438
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 represents the indes of the actual DataGrid and not the DataView. For example.. Lets say I have 4 rows of data.. In the 4 rows I have an Appt Num of 1,2,3,4... Each representing a data row... I sort DESC so the rows display 4,3,2,1... If I...
0
3635
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 datagrid on the left side that lists names and perhaps a couple of other key fields. The user can click on a record in the datagrid, which should automatically pull up details on that record in the various text boxes and other controls on the right...
2
1834
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 new XmlDocument. What is the best way to do this ? I'm thinking just catching an exception and building a new doc isn't the best way of doing this.
3
1203
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. Scenario 1 - brute force Load xml into XmlDocument, txtName.Text = doc.SelectSingleNode ('\\bla\@bla").Value
4
1509
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 VB.NET) that handles the SortCommand event of the data grid. I've included the declaration of the Sub below. EnableViewState is set to false; we reload the DataSource each time the page posts. Would anyone know why this DataGrid doesn't sort? ...
19
2444
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 would like to sort the arraylist based on object.name - is that possible? Thanks! Derek
4
1637
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 accesses data in an SQL Server database. I have developed a couple of pages that display data successfully. However, there is one area that I am having trouble getting a handle on, despite purchasing a couple of Wrox books. Up until now, I have...
4
1537
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 create a new row in the DataGrid and set the date to me within the current sort range, the newly created row "jumps" to its correct position in the grid. This obviously makes sense because it is following the sort rule.
0
8323
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8838
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8739
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
6176
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5638
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4173
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4329
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1969
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1732
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.