473,403 Members | 2,338 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

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 8486
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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,...
0
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...

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.