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

Home Posts Topics Members FAQ

Sorting XML using XMLDOM without using XSL

Hi,

I've had an ASP project dumped on me written in VBScript. I'm actually a
C#/ASP.NET developer and am struggling trying to find a way to sort the
result of a XPath query executed using SelectNodes?

I'd rather not rely on external XSL files if possible.

Any help gratefully received.

Ben
Dec 9 '05 #1
5 8488
Ben Fidge wrote:
Hi,

I've had an ASP project dumped on me written in VBScript. I'm
actually a C#/ASP.NET developer and am struggling trying to find a
way to sort the result of a XPath query executed using SelectNodes?

I'd rather not rely on external XSL files if possible.

Any help gratefully received.

Ben


Short of writing your own procedure to sort the document, an xsl
transformation is the only way. Why are you opposed to this? There are
plenty of already-written xsl examples that can easily be found via a google
search.

--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
Dec 9 '05 #2
I'm not opposed to it, I just don't have the time to sit down and learn XSL.
I was kind of hoping for a quick fix so that I can lay the thing to rest.

In .Net you can apply transformations to an XPath query in situ, whcih is
what i'm used to doing, so was hoping there was a similar method with MSXML.
"Bob Barrows [MVP]" wrote:
Ben Fidge wrote:
Hi,

I've had an ASP project dumped on me written in VBScript. I'm
actually a C#/ASP.NET developer and am struggling trying to find a
way to sort the result of a XPath query executed using SelectNodes?

I'd rather not rely on external XSL files if possible.

Any help gratefully received.

Ben


Short of writing your own procedure to sort the document, an xsl
transformation is the only way. Why are you opposed to this? There are
plenty of already-written xsl examples that can easily be found via a google
search.

--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"

Dec 9 '05 #3
Hi Ben,
I'm not opposed to it, I just don't have the time to sit down and learn XSL. I was kind of hoping for a quick fix so that I can lay the thing to rest.
I've just been working on a similar project, and I'd say the XSL is worth
the effort. Manipulating nodes in code is horrible.
In .Net you can apply transformations to an XPath query in situ, whcih is
what i'm used to doing, so was hoping there was a similar method with

MSXML.

Can you elaborate? In MSXML you can apply a transform too, but I don't
understand what you mean by "XPath query in situ"? Can you give me a URL to
the .NET page about this and I'll have a look.

--
Gerry Hickman
SSRU SysAdmin
Dec 12 '05 #4
Hi Gerry,

Below is an extraction from a C#/Xml project I worked on a while ago. It
shows how XPath is used to get a list of nodes, and how the sorting done too:

XPathDocument oDocCat = new XPathDocument(FsIndexFile);
try {
XPathNavigator oNav = oDocCat.CreateNavigator();
XPathExpression oExpr =
oNav.Compile(string.Format("/images/image[category[@level1id='{0}' or
@level2id='{0}' or @level3id='{0}']]", FsCategoryID));

oExpr.AddSort("@" + FsSortField, XmlSortOrder.Ascending,
XmlCaseOrder.None, "", XmlDataType.Text);

if (oExpr != null) {
XPathNodeIterator oIterator = oNav.Select(oExpr);

while (oIterator.MoveNext()) {
oList.Add(oIterator.Current.GetAttribute("id", ""));
}
}
}
finally {
oDocCat = null;
}

I was hoping MSXML allows you to append sort information to an XPath query
ad-hoc.

Ben

"Gerry Hickman" wrote:
Hi Ben,
I'm not opposed to it, I just don't have the time to sit down and learn

XSL.
I was kind of hoping for a quick fix so that I can lay the thing to rest.


I've just been working on a similar project, and I'd say the XSL is worth
the effort. Manipulating nodes in code is horrible.
In .Net you can apply transformations to an XPath query in situ, whcih is
what i'm used to doing, so was hoping there was a similar method with

MSXML.

Can you elaborate? In MSXML you can apply a transform too, but I don't
understand what you mean by "XPath query in situ"? Can you give me a URL to
the .NET page about this and I'll have a look.

--
Gerry Hickman
SSRU SysAdmin

Dec 13 '05 #5
Hi Ben,

Interesting; I don't see an equivalent in MSXML; it looks like you'd
have to use an in-memory XSL sheet and then use this to transform the
in-memory DOM. In theory quite easy, but I have not actually tried it!

Ben Fidge wrote:
Hi Gerry,

Below is an extraction from a C#/Xml project I worked on a while ago. It
shows how XPath is used to get a list of nodes, and how the sorting done too:

XPathDocument oDocCat = new XPathDocument(FsIndexFile);
try {
XPathNavigator oNav = oDocCat.CreateNavigator();
XPathExpression oExpr =
oNav.Compile(string.Format("/images/image[category[@level1id='{0}' or
@level2id='{0}' or @level3id='{0}']]", FsCategoryID));

oExpr.AddSort("@" + FsSortField, XmlSortOrder.Ascending,
XmlCaseOrder.None, "", XmlDataType.Text);

if (oExpr != null) {
XPathNodeIterator oIterator = oNav.Select(oExpr);

while (oIterator.MoveNext()) {
oList.Add(oIterator.Current.GetAttribute("id", ""));
}
}
}
finally {
oDocCat = null;
}

I was hoping MSXML allows you to append sort information to an XPath query
ad-hoc.

Ben

"Gerry Hickman" wrote:
Hi Ben,
I'm not opposed to it, I just don't have the time to sit down and learn

XSL.
I was kind of hoping for a quick fix so that I can lay the thing to rest.

I've just been working on a similar project, and I'd say the XSL is worth
the effort. Manipulating nodes in code is horrible.
In .Net you can apply transformations to an XPath query in situ, whcih is
what i'm used to doing, so was hoping there was a similar method with

MSXML.

Can you elaborate? In MSXML you can apply a transform too, but I don't
understand what you mean by "XPath query in situ"? Can you give me a URL to
the .NET page about this and I'll have a look.

--
Gerry Hickman
SSRU SysAdmin

--
Gerry Hickman (London UK)
Dec 13 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: VK | last post by:
Dear All: I have an issue trying to parse response from xml document, for that matter I don't receive back response. I am trying to integrate UPS e-commerce online tool into our web site,...
0
by: ck388 | last post by:
For some reason when I enable the callback feature of the gridview I still get a page refresh, that is it seems like there is a postback that occurs, not a callback which is just supposed to update...
7
by: Federico G. Babelis | last post by:
Hi All: I have this line of code, but the syntax check in VB.NET 2003 and also in VB.NET 2005 Beta 2 shows as unknown: Dim local4 As Byte Fixed(local4 = AddressOf dest(offset)) ...
4
by: suzy | last post by:
hello. how can i sort data in a dataset? all the examples i have seen on msdn, etc are sorting a dataview. this works fine, but i want to return the results in xml and the dataview doesn't...
0
by: Ben Fidge | last post by:
Hi, I've had an ASP project dumped on me written in VBScript. I'm actually a C#/ASP.NET developer and am struggling trying to find a way to sort the result of a XPath query executed using...
2
by: =?Utf-8?B?YzY3NjIyOA==?= | last post by:
Hi all, I have the following code which I try to load an xml file, but in browser, I only get text value for each node, not whole xml string. I expect to see something like <name...
2
by: Joey Martin | last post by:
I'll try to make my explanation as thorough as possible. I am trying to grab the value of the node that is returned. MY CODE: Set xmlhttp = CreateObject("Microsoft.XMLHTTP") xmlhttp.open...
6
by: =?Utf-8?B?RGFu?= | last post by:
I am reposting a question from about 3 weeks ago ("sorting capability"). I have an aspx page in which I get the data from a database dynamically, through C# code, by creating a dynamic table...
1
AnuSumesh
by: AnuSumesh | last post by:
Hi, I want to read the text property of XML file. My xml file is as follows: <?xml version="1.0"?> <Domain_Credentials> <User> anu </User>
0
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...
0
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...
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: 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: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.