HisServant
Technical User
Hi,
I'm currently busy with a project, having never done XML before... big learning curve for me.
Maybe I'm just not cut out for this whole development thing, but I'm trying and currently failing.
Please could someone point out what I'm doing wrong?
Thanks in advance!!!!
The code I've got to work from to make up the XML file is:
'--------------------------------------------------------------------------
'DB Connection Settings
'--------------------------------------------------------------------------
Application("DSN_TIMEOUT") = (objxmldom.selectSingleNode("/STARTINGXML/XMLPROJECT_DSN/@timeout").text)
Application("XMLPROJECT_UID") = (objxmldom.selectSingleNode("/STARTINGXML/XMLPROJECT_DSN/XMLPROJECT_DB/@uid").text)
Application("XMLPROJECT_PWD") = (objxmldom.selectSingleNode("/STARTINGXML/XMLPROJECT_DSN/XMLPROJECT_DB/@pwd").text)
Application("XMLPROJECT_DATASOURCE") = (objxmldom.selectSingleNode("/STARTINGXML/XMLPROJECT_DSN/XMLPROJECT_DB/@datasource").text)
Application("XMLPROJECT_CATALOG") = (objxmldom.selectSingleNode("/STARTINGXML/XMLPROJECT_DSN/XMLPROJECT_DB/@db").text)
'--------------------------------------------------------------------------
' Application Built Setting (DO NOT EDIT)
'--------------------------------------------------------------------------
Domain = LCase((objxmldom.selectSingleNode("/STARTINGXML/DOMAIN/@name").text))
PostBackDomain = LCase((objxmldom.selectSingleNode("/STARTINGXML/POSTBACK_DOMAIN/@name").text))
AppPath = LCase((objxmldom.selectSingleNode("/STARTINGXML/APP_PATH/@path").text))
Application("URLSERVER") = Domain + AppPath
'--------------------------------------------------------------------------
'STARTINGXMLurable My Project Settings
'--------------------------------------------------------------------------
Application("XMLPROJECT_NAME") = (objxmldom.selectSingleNode("/STARTINGXML/@name").text)
Application("SERVERID") = (objxmldom.selectSingleNode("/STARTINGXML/@id").text)
Application("XMLPROJECT_HOME_URL") = (objxmldom.selectSingleNode("/STARTINGXML/XMLPROJECT_HOME_URL/@url").text)
Application("SHOW_PENDING_DEPOSITS")= (objxmldom.selectSingleNode("/STARTINGXML/SHOW_PENDING_DEPOSITS/@enabled").text)
Application("SHOW_SPECIAL_OFFERS") = (objxmldom.selectSingleNode("/STARTINGXML/SHOW_SPECIAL_OFFERS/@enabled").text)
Application("SHOW_ADMIN_EVENTS") = (objxmldom.selectSingleNode("/STARTINGXML/SHOW_ADMIN_EVENTS/@enabled").text)
'--------------------------------------------------------------------------
'Logging Settings
'-------------------------------------------------------------------------------------
Application("ENABLE_LOGGING") = (objxmldom.selectSingleNode("/STARTINGXML/LOGFILE/@enabled").text)
if Application("ENABLE_LOGGING") then
Application("LOGFILE") = (objxmldom.selectSingleNode("/STARTINGXML/LOGFILE/@path").text)
end if
'--------------------------------------------------------------------------
'Supported Languages
'-------------------------------------------------------------------------------------
dim fs : set fs = Server.CreateObject("Scripting.FileSystemObject")
dim langList()
dim x : x = 0
for x = 0 to (objxmldom.selectNodes("/STARTINGXML/SUPPORTEDLANGUAGES").length-1)
if (LCase(objxmldom.selectNodes("/STARTINGXML/SUPPORTEDLANGUAGES/@enabled").item(x).text)) then
dim arrLanguage : arrLanguage = split(objxmldom.selectNodes("/STARTINGXML/SUPPORTEDLANGUAGES/@name").item(x).text,",")
dim strLanguage : strLanguage = arrLanguage(0) 'Language code in position 1 will be the file that is used 'objxmldom.selectNodes("/STARTINGXML/SUPPORTEDLANGUAGES/@name").item(x).text
dim file : file = AppPath & "\common\xml\XMLPROJECT_" & strLanguage & ".xml"
dim LangAvail : LangAvail = fs.FileExists (Server.MapPath(file))
if (LangAvail) then
set oXmlDomApp = server.CreateObject("MSXML2.FreeThreadedDOMDocument.4.0")
oXmlDomApp.Load(Server.MapPath(file))
set Application("XML_" & arrLanguage(0)) = oXmlDomApp
set oXmlDomApp = nothing
redim preserve langList(x)
langList(x) = objxmldom.selectNodes("/STARTINGXML/SUPPORTEDLANGUAGES/@name").item(x).text
end if
end if
next
Application("LANGLIST") = langList
set fs = nothing
end if
set objxmldom = nothing
end function
function getAppXml(str)
dim Language, arrSubLang
dim arrLangList : arrLangList = Application("LANGLIST")
dim foundLang : foundLang = false
dim MainDialect : MainDialect = ""
dim i : i = 0
dim a : a = 0
for i = 0 to UBound(arrLangList)
redim arrSubLang(UBound(arrLangList)-1)
arrSubLang = Split(arrLangList(i),",")
for a = 0 to UBound(arrSubLang)
if (arrSubLang(a) = str) then
a = UBound(arrSubLang)
i = UBound(arrLangList)
UsedLang = arrSubLang(0)
Language = "XML_" & arrSubLang(0)
foundLang = true
end if
next
next
if (not(foundLang)) then
redim MainDialect(UBound(Split(str,"-")))
MainDialect = Split(str,"-")
for i = 0 to UBound(arrLangList)
redim arrSubLang(UBound(arrLangList)-1)
arrSubLang = Split(arrLangList(i),",")
for a = 0 to UBound(arrSubLang)
if (arrSubLang(a) = MainDialect(0)) then
a = UBound(arrSubLang)
i = UBound(arrLangList)
UsedLang = arrSubLang(0)
Language = "XML_" & arrSubLang(0)
foundLang = true
end if
next
next
end if
if (not(foundLang)) then
Language = "XML_en"
UsedLang = "en"
end if
on error resume next
set getAppXml = Application(Language)
if (err.number <> 0) then
Language = "XML_en"
UsedLang = "en"
set getAppXml = Application(Language)
end if
end function
The XML I've come up with is this:
<STARTINGXML name="XMLPROJECT" id="10">
<APP_PATH path="C:\XMLPROJECT\"></APP_PATH>
<DOMAIN name="XMLPROJECT"></DOMAIN>
<LOGFILE enabled="true" path="/XMLPROJECT/ver24/logs/"></LOGFILE>
<XMLPROJECT_DSN timeout="10000">
<XMLPROJECT_DB datasource="DRIVER={MySQL ODBC 3.51 Driver}" db="omegasun" pwd="surfing123" uid="root"></XMLPROJECT_DB>
</XMLPROJECT_DSN>
<XMLPROJECT_HOME_URL url="/XMLPROJECT/default.asp"></XMLPROJECT_HOME_URL>
<POSTBACK_DOMAIN name="XMLPROJECT"></POSTBACK_DOMAIN>
<SHOW_ADMIN_EVENTS enabled="true"></SHOW_ADMIN_EVENTS>
<SHOW_PENDING_DEPOSITS enabled="true"></SHOW_PENDING_DEPOSITS>
<SHOW_SPECIAL_OFFERS enabled="true"></SHOW_SPECIAL_OFFERS>
<SUPPORTEDLANGUAGES enabled="true" name="en">0</SUPPORTEDLANGUAGES>
</STARTINGXML>
I'm currently busy with a project, having never done XML before... big learning curve for me.
Maybe I'm just not cut out for this whole development thing, but I'm trying and currently failing.
Please could someone point out what I'm doing wrong?
Thanks in advance!!!!
The code I've got to work from to make up the XML file is:
'--------------------------------------------------------------------------
'DB Connection Settings
'--------------------------------------------------------------------------
Application("DSN_TIMEOUT") = (objxmldom.selectSingleNode("/STARTINGXML/XMLPROJECT_DSN/@timeout").text)
Application("XMLPROJECT_UID") = (objxmldom.selectSingleNode("/STARTINGXML/XMLPROJECT_DSN/XMLPROJECT_DB/@uid").text)
Application("XMLPROJECT_PWD") = (objxmldom.selectSingleNode("/STARTINGXML/XMLPROJECT_DSN/XMLPROJECT_DB/@pwd").text)
Application("XMLPROJECT_DATASOURCE") = (objxmldom.selectSingleNode("/STARTINGXML/XMLPROJECT_DSN/XMLPROJECT_DB/@datasource").text)
Application("XMLPROJECT_CATALOG") = (objxmldom.selectSingleNode("/STARTINGXML/XMLPROJECT_DSN/XMLPROJECT_DB/@db").text)
'--------------------------------------------------------------------------
' Application Built Setting (DO NOT EDIT)
'--------------------------------------------------------------------------
Domain = LCase((objxmldom.selectSingleNode("/STARTINGXML/DOMAIN/@name").text))
PostBackDomain = LCase((objxmldom.selectSingleNode("/STARTINGXML/POSTBACK_DOMAIN/@name").text))
AppPath = LCase((objxmldom.selectSingleNode("/STARTINGXML/APP_PATH/@path").text))
Application("URLSERVER") = Domain + AppPath
'--------------------------------------------------------------------------
'STARTINGXMLurable My Project Settings
'--------------------------------------------------------------------------
Application("XMLPROJECT_NAME") = (objxmldom.selectSingleNode("/STARTINGXML/@name").text)
Application("SERVERID") = (objxmldom.selectSingleNode("/STARTINGXML/@id").text)
Application("XMLPROJECT_HOME_URL") = (objxmldom.selectSingleNode("/STARTINGXML/XMLPROJECT_HOME_URL/@url").text)
Application("SHOW_PENDING_DEPOSITS")= (objxmldom.selectSingleNode("/STARTINGXML/SHOW_PENDING_DEPOSITS/@enabled").text)
Application("SHOW_SPECIAL_OFFERS") = (objxmldom.selectSingleNode("/STARTINGXML/SHOW_SPECIAL_OFFERS/@enabled").text)
Application("SHOW_ADMIN_EVENTS") = (objxmldom.selectSingleNode("/STARTINGXML/SHOW_ADMIN_EVENTS/@enabled").text)
'--------------------------------------------------------------------------
'Logging Settings
'-------------------------------------------------------------------------------------
Application("ENABLE_LOGGING") = (objxmldom.selectSingleNode("/STARTINGXML/LOGFILE/@enabled").text)
if Application("ENABLE_LOGGING") then
Application("LOGFILE") = (objxmldom.selectSingleNode("/STARTINGXML/LOGFILE/@path").text)
end if
'--------------------------------------------------------------------------
'Supported Languages
'-------------------------------------------------------------------------------------
dim fs : set fs = Server.CreateObject("Scripting.FileSystemObject")
dim langList()
dim x : x = 0
for x = 0 to (objxmldom.selectNodes("/STARTINGXML/SUPPORTEDLANGUAGES").length-1)
if (LCase(objxmldom.selectNodes("/STARTINGXML/SUPPORTEDLANGUAGES/@enabled").item(x).text)) then
dim arrLanguage : arrLanguage = split(objxmldom.selectNodes("/STARTINGXML/SUPPORTEDLANGUAGES/@name").item(x).text,",")
dim strLanguage : strLanguage = arrLanguage(0) 'Language code in position 1 will be the file that is used 'objxmldom.selectNodes("/STARTINGXML/SUPPORTEDLANGUAGES/@name").item(x).text
dim file : file = AppPath & "\common\xml\XMLPROJECT_" & strLanguage & ".xml"
dim LangAvail : LangAvail = fs.FileExists (Server.MapPath(file))
if (LangAvail) then
set oXmlDomApp = server.CreateObject("MSXML2.FreeThreadedDOMDocument.4.0")
oXmlDomApp.Load(Server.MapPath(file))
set Application("XML_" & arrLanguage(0)) = oXmlDomApp
set oXmlDomApp = nothing
redim preserve langList(x)
langList(x) = objxmldom.selectNodes("/STARTINGXML/SUPPORTEDLANGUAGES/@name").item(x).text
end if
end if
next
Application("LANGLIST") = langList
set fs = nothing
end if
set objxmldom = nothing
end function
function getAppXml(str)
dim Language, arrSubLang
dim arrLangList : arrLangList = Application("LANGLIST")
dim foundLang : foundLang = false
dim MainDialect : MainDialect = ""
dim i : i = 0
dim a : a = 0
for i = 0 to UBound(arrLangList)
redim arrSubLang(UBound(arrLangList)-1)
arrSubLang = Split(arrLangList(i),",")
for a = 0 to UBound(arrSubLang)
if (arrSubLang(a) = str) then
a = UBound(arrSubLang)
i = UBound(arrLangList)
UsedLang = arrSubLang(0)
Language = "XML_" & arrSubLang(0)
foundLang = true
end if
next
next
if (not(foundLang)) then
redim MainDialect(UBound(Split(str,"-")))
MainDialect = Split(str,"-")
for i = 0 to UBound(arrLangList)
redim arrSubLang(UBound(arrLangList)-1)
arrSubLang = Split(arrLangList(i),",")
for a = 0 to UBound(arrSubLang)
if (arrSubLang(a) = MainDialect(0)) then
a = UBound(arrSubLang)
i = UBound(arrLangList)
UsedLang = arrSubLang(0)
Language = "XML_" & arrSubLang(0)
foundLang = true
end if
next
next
end if
if (not(foundLang)) then
Language = "XML_en"
UsedLang = "en"
end if
on error resume next
set getAppXml = Application(Language)
if (err.number <> 0) then
Language = "XML_en"
UsedLang = "en"
set getAppXml = Application(Language)
end if
end function
The XML I've come up with is this:
<STARTINGXML name="XMLPROJECT" id="10">
<APP_PATH path="C:\XMLPROJECT\"></APP_PATH>
<DOMAIN name="XMLPROJECT"></DOMAIN>
<LOGFILE enabled="true" path="/XMLPROJECT/ver24/logs/"></LOGFILE>
<XMLPROJECT_DSN timeout="10000">
<XMLPROJECT_DB datasource="DRIVER={MySQL ODBC 3.51 Driver}" db="omegasun" pwd="surfing123" uid="root"></XMLPROJECT_DB>
</XMLPROJECT_DSN>
<XMLPROJECT_HOME_URL url="/XMLPROJECT/default.asp"></XMLPROJECT_HOME_URL>
<POSTBACK_DOMAIN name="XMLPROJECT"></POSTBACK_DOMAIN>
<SHOW_ADMIN_EVENTS enabled="true"></SHOW_ADMIN_EVENTS>
<SHOW_PENDING_DEPOSITS enabled="true"></SHOW_PENDING_DEPOSITS>
<SHOW_SPECIAL_OFFERS enabled="true"></SHOW_SPECIAL_OFFERS>
<SUPPORTEDLANGUAGES enabled="true" name="en">0</SUPPORTEDLANGUAGES>
</STARTINGXML>