ASP with XML - The whole truth
Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=12173
Printed Date: 30 March 2026 at 7:50pm Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com
Topic: ASP with XML - The whole truth
Posted By: theSCIENTIST
Subject: ASP with XML - The whole truth
Date Posted: 14 October 2004 at 3:29pm
Guys, I need your expert guidance on this matter, as it is the first time, beleive it or not, that I'm using ASP with XML, I used XML before, bot not with ASP.
The project I'm working on, relies on XML files to supply language values for all ASP files, so a user can easily change the language of the whole web site.
I'm using this code to read XML:
Dim dXML, txtTitle, txtSelect
Set dXML = Server.CreateObject("Microsoft.XMLDOM")
dXML.Async = False
If Request.Cookies("Cook")("Language") = "" Then dXML.Load(Server.MapPath("languages/English/news_lang.xml"))
If Request.Cookies("Cook")("Language") = "English" Then dXML.Load(Server.MapPath("languages/English/news_lang.xml"))
If Request.Cookies("Cook")("Language") = "Portuguese" Then dXML.Load(Server.MapPath("languages/Portuguese/news_lang.xml "))
If dXML.parseError.ErrorCode <> 0 Then
Response.Write = "God damn another xmlErr!"
Else
txtTitle = dXML.documentElement.childNodes(txtTitle).Text
txtSelect = dXML.selectSingleNode("Language/txtSelect").nodeTypedValue
End If
Set dXML = Nothing |
And here's the XML file:
<?xml version="1.0" encoding="UTF-8" ?>
<Language>
<txtTitle>MyApp Name</txtTitle>
<txtSelect>Select:</txtSelect>
</Language> |
My questions are mainly towards the ASP XML processing, in particular, where this line is concerned (dXML.Async = False) it appears it locks the XML file before the reading, what are the implications of this when there are dozens of users all requesting and changing language info?
Also, note that to retrive XML values I'm using 2 different methods:
1. txtTitle = dXML.documentElement.childNodes(txtTitle).Text
2. txtSelect = dXML.selectSingleNode("Language/txtSelect").nodeTypedValue
Which is the most efficient to use? On the first one you say you want to retrive a child, give it's name and that's it, however the second method allows you to specify which parent also, are there any preformance or any other problem with any one of them?
Also, I would like to have a common file that will do all this XML extraction, but all and every ASP page will have it's own XML language file with all variables used in it, so my approach to have a common file to process so many different XML files may not work well, so I thought to include the code above on top of every ASP page and change it to reflect the variables used.
Is my whole approach viable at all?
------------- :: http://www.mylittlehost.com/ - www.mylittlehost.com
|
Replies:
Posted By: michael
Date Posted: 14 October 2004 at 4:23pm
Well I do not have too much knowledge of XML in ASP but generally when I want to populate variables from a XML file, at least in .net I just open the file once and go something like
While myxml.Read()
var1=...
var2=...
That way I do not have to make multiple connections to the xml file which will slow it down a bit. Using that method you should not have to worry about how to talk to the node as it quickly reads all nodes and you just place them.....Hope I make sense here. Let me know if you need more detail..
------------- http://baumannphoto.com" rel="nofollow - Blog | http://mpgtracker.com" rel="nofollow - MPG Tracker
|
Posted By: theSCIENTIST
Date Posted: 15 October 2004 at 2:36pm
I guess there's no way to simulate the results of such approach, the little stress caused is not significative, so I'll run all tests when app goes live with beta testing, but if it is wrong it will be hell to correct.
Thx.
------------- :: http://www.mylittlehost.com/ - www.mylittlehost.com
|
|