seoirse
asked on
Very NB: Reading and Parsing xml file in reverse order
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.getElementsByTagNam e("newsite m")
Set ChannList = objXML.getElementsByTagNam e("channel ")
'On Error Resume Next
for c = 0 to (ChannList.length - 1)
if (ChannList.item(c).attribu tes(0).nod eValue = 8) then
' read elements from xml file
for i = 0 to (ChannList.item(c).childNo des.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).childNo des.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?
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.getElementsByTagNam
Set ChannList = objXML.getElementsByTagNam
'On Error Resume Next
for c = 0 to (ChannList.length - 1)
if (ChannList.item(c).attribu
' read elements from xml file
for i = 0 to (ChannList.item(c).childNo
'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).childNo
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?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER