By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,948 Members | 663 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,948 IT Pros & Developers. It's quick & easy.

blank lines screwing up XMLDocument object

P: n/a
I have an XMLDocument object that is attempting to parse an xml document
generated by a cold fusion page. The problem is that for some reason the cold
fusion page is generating a number of carriage returns preceding the XML
declaration. This is causing the following error:

System.Xml.XmlException: The XML declaration is unexpected. Line 80,
position 3. at System.Xml.XmlTextReader.ParseTag() at
System.Xml.XmlTextReader.ParseRoot() at System.Xml.XmlTextReader.Read() at
System.Xml.XmlValidatingReader.ReadWithCollectText Token() at
System.Xml.XmlValidatingReader.Read() at
System.Xml.XmlLoader.LoadDocSequence(XmlDocument parentDoc) at
System.Xml.XmlLoader.Load(XmlDocument doc, XmlReader reader, Boolean
preserveWhitespace) at System.Xml.XmlDocument.Load(XmlReader reader) at
System.Xml.XmlDocument.Load(String filename) at
ASP.MessageBuilder_aspx.Page_Load(Object Sender, EventArgs E) in
C:\Inetpub\wwwroot\printmanager\helpercomponents\m essagebuilder.aspx:line 32

Is there any way to make the XmlDocument object ignore these carriage
returns? I've tried (to no avail) to make coldfusion suppress them. I've
tried setting "preservewhitespace" to true but it doesn't recognize carriage
returns. Line of code generating the error is:

objMessageToSend.Load("http://192.168.1.13/SCR4/PrintManagerGateWay.cfm?AgreementId=1152074")
Mar 15 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a


Glenn Venzke wrote:
I have an XMLDocument object that is attempting to parse an xml document
generated by a cold fusion page. The problem is that for some reason the cold
fusion page is generating a number of carriage returns preceding the XML
declaration. This is causing the following error:

System.Xml.XmlException: The XML declaration is unexpected. Line 80,
Is there any way to make the XmlDocument object ignore these carriage
returns?


I don't think so, there are no line breaks allowed before the XML
declaration, otherwise the markup is not well-formed XML at all and any
XML parser has to reject it.
--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Mar 16 '06 #2

P: n/a
Glenn Venzke wrote:
I have an XMLDocument object that is attempting to parse an xml document
generated by a cold fusion page. The problem is that for some reason the cold
fusion page is generating a number of carriage returns preceding the XML
declaration. This is causing the following error:
Indeed it would. White-space before the XML Declaration is prohibited
by the Spec.

[snip] Is there any way to make the XmlDocument object ignore these carriage
returns? I've tried (to no avail) to make coldfusion suppress them.


Sounds like CF has a bug. The temporary way round it would be to pass
the document through a little script that eats all white-space before
the first <?

///Peter
Mar 16 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.