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?