Solved

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

Posted on 2009-06-27
4
1,171 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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

IP addresses can be stored in a database in any of several ways.  These ways may vary based on the volume of the data.  I was dealing with quite a large amount of data for user authentication purpose, and needed a way to minimize the storage.   …
For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…

627 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