Connecting Tech Pros Worldwide Help | Site Map

blank lines screwing up XMLDocument object

  #1  
Old March 15th, 2006, 11:45 PM
Glenn Venzke
Guest
 
Posts: 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")
  #2  
Old March 16th, 2006, 01:15 PM
Martin Honnen
Guest
 
Posts: n/a

re: blank lines screwing up XMLDocument object




Glenn Venzke wrote:
[color=blue]
> 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,[/color]

[color=blue]
> Is there any way to make the XmlDocument object ignore these carriage
> returns?[/color]

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/
  #3  
Old March 16th, 2006, 09:25 PM
Peter Flynn
Guest
 
Posts: n/a

re: blank lines screwing up XMLDocument object


Glenn Venzke wrote:[color=blue]
> 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:[/color]

Indeed it would. White-space before the XML Declaration is prohibited
by the Spec.

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

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
Closed Thread