Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

ASP giving error when i try to use Server.CreateObject("Microsoft.XMLDOM")

Posted on 2009-07-16
20
Medium Priority
?
3,417 Views
Last Modified: 2012-05-07
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("Microsoft.XMLDOM")%>

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
 %>

Open in new window

0
Comment
Question by:corthezz
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 9
  • 6
  • 5
20 Comments
 
LVL 11

Expert Comment

by:Andrei Teodorescu
ID: 24867331
pls, provide linx.xml example
0
 
LVL 11

Expert Comment

by:Sven
ID: 24867339
Try
Set objXML = CreateObject("MSXML2.DOMDocument")

Or by Version
Set objXML = CreateObject("MSXML2.DOMDocument.3.0")
Set objXML = CreateObject("MSXML2.DOMDocument.4.0")
Set objXML = CreateObject("MSXML2.DOMDocument.6.0")
0
 
LVL 11

Expert Comment

by:Sven
ID: 24867363
Also you do not need the lines:
Set objLst = Server.CreateObject("Microsoft.XMLDOM")
Set objHdl = Server.CreateObject("Microsoft.XMLDOM")

You should remove them espacially because you are not destroying these objects before creating new ones with
Set objLst = objXML.getElementsByTagName("mainmenu")
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



0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:corthezz
ID: 24867384
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)>


0
 
LVL 11

Expert Comment

by:Sven
ID: 24867397
Post the exact error and line number and the exact line from the code that got the error.
0
 

Author Comment

by:corthezz
ID: 24867415
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())%>
0
 
LVL 11

Accepted Solution

by:
Andrei Teodorescu earned 1400 total points
ID: 24867419
is working here
reinstall XML from scratch...
<%
Dim objXML, objLst, objHdl
Set objXML = 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
 %>

Open in new window

untitled.PNG
0
 

Author Comment

by:corthezz
ID: 24867423
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
0
 

Author Comment

by:corthezz
ID: 24867442
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
0
 
LVL 11

Expert Comment

by:Andrei Teodorescu
ID: 24867464
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?
0
 

Author Comment

by:corthezz
ID: 24867500
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\LAYOUTS\plautwelcome\pwelcome.aspx

without that code the page is working correctly.
0
 
LVL 11

Assisted Solution

by:Andrei Teodorescu
Andrei Teodorescu earned 1400 total points
ID: 24867507
you'll have to host the page on a diff. site (URL with a dif. hostheader/port) and include it in sharepoint using a Page Viewer WebPart
0
 

Author Comment

by:corthezz
ID: 24867510
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...
0
 
LVL 11

Expert Comment

by:Andrei Teodorescu
ID: 24867518
0
 

Author Comment

by:corthezz
ID: 24867619
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.
0
 

Author Comment

by:corthezz
ID: 24867818
I getting this error message. Any ideas?
error.jpg
0
 
LVL 11

Assisted Solution

by:Sven
Sven earned 600 total points
ID: 24867842
You are using ASP Classic Code in a ASP.NET application? That can not work.

Rename file to .asp instead of .aspx or recode to ASP.NET!
0
 
LVL 11

Assisted Solution

by:Andrei Teodorescu
Andrei Teodorescu earned 1400 total points
ID: 24867917
indeed, rename to .asp; I wasn't paying att. to the file extension
0
 
LVL 11

Expert Comment

by:Sven
ID: 24867975
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.
0
 

Author Comment

by:corthezz
ID: 24868233
Great! its working now! Thanx so much!
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Lync server 2013 or Skype for business Backup Service Error ID 4049 – After File Share Migration
When using a search centre, I'm going to show you how to configure Sharepoint's search to only return results from the current site collection. Very useful when using Office 365 with multiple site collections.
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question