Solved

"Cannot have a DOCTYPE declaration outside of a prolog" on LoadXML in VB Macro

Posted on 2009-06-27
4
1,157 Views
Last Modified: 2013-12-17
I've been searching for several hours for this and decided to post my first post here.  I have an Excel Macro written in VB that is calling a WebService (written in ASP.net/C#).  The WebService then returns an XML string to Excel.  When the macro does a "LoadXML()" .. i get the "Cannot have a DOCTYPE declaration outside of a prolog."

I ran the XML string through a validator to make sure it was well-formed and it is.  This is a snippit of the XML returned to Excel (it's a pretty long string):

XML
--------------
<risk><result>true</result><message />
<currentdata>
<mydata><id>20531</id></mydata> ...
</currentdata>
</risk>

VB:
--------------------------------
Dim oMessageXML As New MSXML2.DOMDocument

oMessageXML.async = False
oMessageXML.LoadXml (xmlMessage)
If (oMessageXML.parseError.errorCode <> 0) Then
   Dim myErr
   Set myErr = oMessageXML.parseError
   MsgBox ("You have error " & myErr.reason & " ErrCode: " & myErr.errorCode)
End If
 ....


Any assistance will be greatly appreciated!!

The XML sent has a format that I then use to build another XML string.  I'm not displaying this.  I just need to read it so I can work with it.

This process used to use an Oracle DB and I am converting it to use SQL Server 2008.  Also the project was initially in VS 2005 and I'm now running it in VS 2008 (for ASP.net).  In the old instance of the project, the XML string sent back looks identical to the one I am receiving in this case.

0
Comment
Question by:burtj
[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
  • 3
4 Comments
 

Author Comment

by:burtj
ID: 24731212
Here's an interesting note ... if I hardcode part of the XML string, it gets past the check.  I hardcoded this .. the actual XML string is really long:

<risk><result>true</result><message /><currdata><sr><srid>20531</srid><ldid>321484</ldid><pricing>2</pricing><proposaldate>1/16/2009 12:00:00 AM</proposaldate><requestdate>12/12/2008 12:00:00 AM</requestdate><comments></comments><createname>HOPE, WILLEM</createname><createdate>12/12/2008 12:00:00 AM</createdate><mdfyname>MOUSE, MICKEY</mdfyname><mdfydate>12/15/2008 12:00:00 AM</mdfydate></sr></currdata><employee><employeecode>81955</employeecode><employeename>FOX, FRED</employeename><ntid>fredfox</ntid></employee><opp><ldid>321484</ldid><lname>Media Business Manage </lname><companyname>CompName, Inc.</companyname></opp></risk>
0
 

Author Comment

by:burtj
ID: 24731227
Is it possible that my XML String is too long?  I just checked ... it has 17592 characters.
0
 
LVL 38

Accepted Solution

by:
PaulHews earned 225 total points
ID: 24732246
No the string is not too long.  The problem is that the asp.net web service is returning more than just XML.  The solution will lie in the code for the web service.  It sounds like it's returning HTML along with the XML, which might mean that you are accessing an ASP.NET webform instead of a web service.

If you are using an ASPX page to return the XML, you have to ensure that you do not have any declared HTML (only the page declaration is required.)  See link for example

http://www.deez.info/sengelha/2006/02/06/how-return-xml-from-aspx-in-aspnet-11/
0
 

Author Comment

by:burtj
ID: 24732558
Paul ... you got it!  In my .aspx file, it had a doctype definition and other HTML ... once I removed that and only left the @Page definition, it worked!  Thank you!!!
0

Featured Post

Enroll in May's Course of the Month

May’s Course of the Month is now available! Experts Exchange’s Premium Members and Team Accounts have access to a complimentary course each month as part of their membership—an extra way to increase training and boost professional development.

Question has a verified solution.

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

Flash (http://en.wikipedia.org/wiki/Adobe_Flash) has evolved over the years to where it has become a masterful tool for displaying content screen.  It has excellent layout placement, UI precision as well as rendering capabilities. This, along with t…
In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

738 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