Solved

Very NB: Reading and Parsing xml file in reverse order

Posted on 2001-08-30
2
276 Views
Last Modified: 2010-05-18
I have an asp program which reads an xml file and loops through the file entering data in a database.
Currently i enter article data in the database in the order in which i meet the articles when reading the xml file from top to bottom. However I now need to read articles from the xml file in bottom to top order.

I am currently reading the xml fiel in the following manner

   Set NewsList = objXML.getElementsByTagName("newsitem")
   Set ChannList = objXML.getElementsByTagName("channel")

   'On Error Resume Next
  for c = 0  to (ChannList.length - 1)

     if (ChannList.item(c).attributes(0).nodeValue = 8) then

        ' read elements from xml file
        for i = 0 to (ChannList.item(c).childNodes.length  - 1)

'read in file data
'check if article already exists in database and if not 'then enter in database

        next
      end if
    next

However if I try to read in article data in decending order by doing the following

  for (ChannList.length - 1) to c = 0

I get the following error "Microsoft VBScript compilation error '800a03f2'

Expected identifier

/xmlupload/xmltest.asp, line 38

for (ChannList.length - 1) to c = 0"

Also when I try to do:
        for (ChannList.item(c).childNodes.length  - 1) to i = 0
I get a similiar error.

It is very important I fix this error as I need to display newsartilcles in decending order as they appear in the xmnl file. However difficulty arises as folows.
if I want to display the latest 50 articles on teh web site and read from the database by id in accending order. The this works fine if there are only 50 articles in the database.
however if i run my asp program again for entering articels from the xml file and 5 new articles are entered in teh database, then the ordering will go out of sinc on the live site as when reading in ascending order, the new articles will be at the end instead of at the beginning.

If you do not know of any solution to my readingn in in xml then do you know of a sql solution i could use forreading my articles in correct order?



0
Comment
Question by:seoirse
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 9

Accepted Solution

by:
AlfaNoMore earned 75 total points
ID: 6440051
for C = (ChannList.length - 1) to 0 Step -1
0
 

Author Comment

by:seoirse
ID: 6440177
thank you, has worked perfectly.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Change visitor's REMOTE_ADDR to server's REMOTE_ADDR 2 51
ASP server side get value 15 50
Validating Date Part2 2 47
JQuery on multiple lines 3 49
Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

759 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question