Solved

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

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Recently while returning home from work my wife (another .NET developer) was murmuring something. On further poking she said that she has been assigned a task where she has to serialize and deserialize objects and she is afraid of serialization. Wha…
This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

706 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now