Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old March 15th, 2006, 11:45 PM
Glenn Venzke
Guest
 
Posts: n/a
Default blank lines screwing up XMLDocument object

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
Default 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
Default 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
 

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles