corthezz
asked on
ASP giving error when i try to use Server.CreateObject("Microsoft.XMLDOM")
I have a server computer with Windows 2008, IIS7 and Sharepoint. I have ASP page inside Sharepoint. I want to read XML file. I have find nice manuals on the internet how to do it. My problem is, that after i put first line of the code i get error message (unknown error).
for example this working: <%Response.Write(now())%>
BUT THIS NOT WORKING: <%Set objXML = Server.CreateObject("Micro soft.XMLDO M")%>
What i tryed:
1.Istalled msxml3.msi (msxml3.dll)
2.Installed XMLinst.exe
3.change object type to Msxml2.DOMDocument.3.0 from Microsoft.XMLDOM
i getting the same error message. Can anybody help me what is missing from my system or how to make it work????
for example this working: <%Response.Write(now())%>
BUT THIS NOT WORKING: <%Set objXML = Server.CreateObject("Micro
What i tryed:
1.Istalled msxml3.msi (msxml3.dll)
2.Installed XMLinst.exe
3.change object type to Msxml2.DOMDocument.3.0 from Microsoft.XMLDOM
i getting the same error message. Can anybody help me what is missing from my system or how to make it work????
this should be the full code:
<%
Set objXML = Server.CreateObject("Microsoft.XMLDOM")
Set objLst = Server.CreateObject("Microsoft.XMLDOM")
Set objHdl = Server.CreateObject("Microsoft.XMLDOM")
objXML.async = False
objXML.Load (Server.MapPath("linx.xml"))
Set objLst = objXML.getElementsByTagName("mainmenu")
menuitemcount = objLst.length
%>
<h1>Testurl:<h1>
<%
For i = 0 To (menuitemcount 1)
Set objHdl = objLst.item(i)
Response.Write("<a href=""" & _
objHdl.childNodes(1).childNodes(0).text & _
""">" & objHdl.childNodes(0).text & _
"</a><br>")
Next
%>
pls, provide linx.xml example
Try
Set objXML = CreateObject("MSXML2.DOMDo cument")
Or by Version
Set objXML = CreateObject("MSXML2.DOMDo cument.3.0 ")
Set objXML = CreateObject("MSXML2.DOMDo cument.4.0 ")
Set objXML = CreateObject("MSXML2.DOMDo cument.6.0 ")
Set objXML = CreateObject("MSXML2.DOMDo
Or by Version
Set objXML = CreateObject("MSXML2.DOMDo
Set objXML = CreateObject("MSXML2.DOMDo
Set objXML = CreateObject("MSXML2.DOMDo
Also you do not need the lines:
Set objLst = Server.CreateObject("Micro soft.XMLDO M")
Set objHdl = Server.CreateObject("Micro soft.XMLDO M")
You should remove them espacially because you are not destroying these objects before creating new ones with
Set objLst = objXML.getElementsByTagNam e("mainmen u")
Set objHdl = objLst.item(i)
Best practice als would be to destroy each object (Set objABC = Nothing) before creating a new one even if it is the same object variable! Example:
For i = 1 To 3
Set objABC = objItem(i)
Response.Write objABC.Text
Set objABC = Nothing
Next
Set objLst = Server.CreateObject("Micro
Set objHdl = Server.CreateObject("Micro
You should remove them espacially because you are not destroying these objects before creating new ones with
Set objLst = objXML.getElementsByTagNam
Set objHdl = objLst.item(i)
Best practice als would be to destroy each object (Set objABC = Nothing) before creating a new one even if it is the same object variable! Example:
For i = 1 To 3
Set objABC = objItem(i)
Response.Write objABC.Text
Set objABC = Nothing
Next
ASKER
LINX XML:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mylinks SYSTEM "linx.dtd">
<mylinks>
<mainmenu>
<url>http://www.google.com</url>
<text>Google</text>
<type>link</type>
</mainmenu>
<mainmenu>
<url>http://www.microsoft.com</url>
<text>Microsoft</text>
<type>link</type>
</mainmenu>
<submenu1>
<url>http://www.google.com</url>
<text>Google</text>
</submenu1>
<submenu2>
<url>http://www.google.com</url>
<text>Google</text>
</submenu2>
<submenu3>
<url>http://www.google.com</url>
<text>Google</text>
</submenu3>
</mylinks>
LINX DTD:
<?xml version="1.0" encoding="UTF-8"?>
<!-- edited with XMLSpy v2009 sp1 (http://www.altova.com) by Corthezz (EMBRACE) -->
<!ELEMENT mylinks (mainmenu*, submenu1*, submenu2*, submenu3*)>
<!ELEMENT mainmenu (url, text, type)>
<!ELEMENT submenu1 (url, text)>
<!ELEMENT submenu2 (url, text)>
<!ELEMENT submenu3 (url, text)>
<!ELEMENT url (#PCDATA)>
<!ELEMENT text (#PCDATA)>
<!ELEMENT type (#PCDATA)>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mylinks SYSTEM "linx.dtd">
<mylinks>
<mainmenu>
<url>http://www.google.com</url>
<text>Google</text>
<type>link</type>
</mainmenu>
<mainmenu>
<url>http://www.microsoft.com</url>
<text>Microsoft</text>
<type>link</type>
</mainmenu>
<submenu1>
<url>http://www.google.com</url>
<text>Google</text>
</submenu1>
<submenu2>
<url>http://www.google.com</url>
<text>Google</text>
</submenu2>
<submenu3>
<url>http://www.google.com</url>
<text>Google</text>
</submenu3>
</mylinks>
LINX DTD:
<?xml version="1.0" encoding="UTF-8"?>
<!-- edited with XMLSpy v2009 sp1 (http://www.altova.com) by Corthezz (EMBRACE) -->
<!ELEMENT mylinks (mainmenu*, submenu1*, submenu2*, submenu3*)>
<!ELEMENT mainmenu (url, text, type)>
<!ELEMENT submenu1 (url, text)>
<!ELEMENT submenu2 (url, text)>
<!ELEMENT submenu3 (url, text)>
<!ELEMENT url (#PCDATA)>
<!ELEMENT text (#PCDATA)>
<!ELEMENT type (#PCDATA)>
Post the exact error and line number and the exact line from the code that got the error.
ASKER
MSXML2.DOMDocument
MSXML2.DOMDocument.3.0
MSXML2.DOMDocument.4.0
MSXML2.DOMDocument.6.0
Microsoft.XMLDOM
I tryed all te version....but the result is the same.. :( I think there is more serious error. only this example working so far: : <%Response.Write(now())%>
MSXML2.DOMDocument.3.0
MSXML2.DOMDocument.4.0
MSXML2.DOMDocument.6.0
Microsoft.XMLDOM
I tryed all te version....but the result is the same.. :( I think there is more serious error. only this example working so far: : <%Response.Write(now())%>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
i getting Sharepoint error. there is no info about line or error code. i dont know how to get it because i am new in ASP
ASKER
Ok, so i think i have problem with the XML dll. Andrei, i have to reinstall IIS component? I haven's installed anything so far
Please provide details of the sharepoint error; prt. screen if no other info is available
You don't have to reinstall anything in IIS
Other aspect, where is that ASP page hosted? The corresponding app pool for that site is the same as for the sharepoint site?
You don't have to reinstall anything in IIS
Other aspect, where is that ASP page hosted? The corresponding app pool for that site is the same as for the sharepoint site?
ASKER
it is inside sharepoint
sharepoint address: http://merkur/_layouts/plautwelcome/pwelcome.aspx
physical address: C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\TEMPLATE\LAY OUTS\plaut welcome\pw elcome.asp x
without that code the page is working correctly.
sharepoint address: http://merkur/_layouts/plautwelcome/pwelcome.aspx
physical address: C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\TEMPLATE\LAY
without that code the page is working correctly.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I am not sure if i have installed everything what i need for working with XML. it seems that IIS cant handle the Server.Createobject() metod...
ASKER
I installed it, but it doesn't work either. I will try to host the page on the different site and i will post the result.
ASKER
I getting this error message. Any ideas?
error.jpg
error.jpg
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Maybe you also have to activate ASP 3.0 in order to run classic ASP and .asp extension.
You have to add this as role of the server in server-manager under control panel.
You have to add this as role of the server in server-manager under control panel.
ASKER
Great! its working now! Thanx so much!