469,632 Members | 1,639 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,632 developers. It's quick & easy.

Error:An unexpected end of file parsing CDATA has occurred.

I am creating a XML document which opens fine in IE. Implies MSXML
thinks it is a well formed document.
But when I try to load this document in VB.net using the following
code
Dim doc As New XmlDocument
doc.Load("C:\Projects\SQLXML\corc.xml")

I get the following error:

"System.Xml.XmlException: An unexpected end of file parsing CDATA has
occurred. Line 6, position 1.
at System.Xml.XmlScanner.ScanCData()
at System.Xml.XmlScanner.ScanMarkup()
at System.Xml.XmlTextReader.ParseTag()
at System.Xml.XmlTextReader.ParseBeginTagExpandCharEn tities()
at System.Xml.XmlTextReader.Read()
at System.Xml.XmlValidatingReader.ReadNoCollectTextTo ken()
at System.Xml.XmlValidatingReader.Read()
at System.Xml.XmlLoader.LoadChildren(XmlNode parent)
at System.Xml.XmlLoader.LoadElementNode()
at System.Xml.XmlLoader.LoadCurrentNode()
at System.Xml.XmlLoader.LoadChildren(XmlNode parent)
at System.Xml.XmlLoader.LoadElementNode()
at System.Xml.XmlLoader.LoadCurrentNode()
at System.Xml.XmlLoader.LoadCurrentNode()
at System.Xml.XmlLoader.LoadChildren(XmlNode parent)
at System.Xml.XmlLoader.LoadElementNode()
at System.Xml.XmlLoader.LoadCurrentNode()
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 SQLXML.Form1.Button4_Click(Object sender, EventArgs e) in
C:\Projects\SQLXML\Form1.vb:line 211"

Here is my document.

<?xml version="1.0" encoding="utf-8" ?>
- <corc xmlns:sql="urn:schemas-microsoft-com:xml-sql"
xmlns="http://tempuri.org/corc.xsd">
- <item projectID="19182">
<JIFNumber>97-545-0100-S</JIFNumber>
<Title>PULSAR MAX II brochure (Spanish)</Title>
<Group>Brady</Group>
<Category>Product brochure</Category>
- <Description>
- <![CDATA[
{\rtf1\ansi\ansicpg1252\deff0{\fonttbl{\f0\fswiss\ fprq2\fcharset0
Tahoma;}{\f1\fnil\fcharset0 Tahoma;}}
{\colortbl ;\red153\green51\blue102;}
\viewkind4\uc1\pard\lang1033\b\f0\fs21 PULSAR MAX II brochure\b0\fs17
(\cf1\b Spanish\cf0\b0\f1\par
}
]]>
</Description>
<ImageFileName>97-545-0100-S.jpg</ImageFileName>
<scoutFeaturedItem>0</scoutFeaturedItem>
- <Characterictic>
<CharacteristicID>2</CharacteristicID>
<CharactericticValue>flying</CharactericticValue>
</Characterictic>
</item>
- <item projectID="19183">
<JIFNumber>99-919-901</JIFNumber>
<Title>Guidant Notepad (OBSOLETE 7/02 - REPLACED WITH
M9-002-00)</Title>
<Group>CRM</Group>
- <Description>
- <![CDATA[ Guidant Notepad (OBSOLETE 7/02 - REPLACED WITH M9-002-00)
]]>
</Description>
<scoutFeaturedItem>0</scoutFeaturedItem>
</item>
- <item projectID="19184">
<JIFNumber>97-718-1102</JIFNumber>
<Title>CONTAK RENEWAL CD ROM</Title>
<Group>Heart Failure</Group>
- <Description>
- <![CDATA[ CONTAK RENEWAL CD ROM
]]>
</Description>
<scoutFeaturedItem>0</scoutFeaturedItem>
</item>
- <item projectID="19186">
<JIFNumber>99-940-102</JIFNumber>
<Title>NASPE 2002 Allied Professional Invitations</Title>
<Group>CRM</Group>
- <Description>
- <![CDATA[ NASPE 2002 Allied Professional Invitations
]]>
</Description>
<scoutFeaturedItem>0</scoutFeaturedItem>
</item>
</corc>
Any help would be appreciated.

Thanks
Nov 12 '05 #1
4 11218
sunil wrote:
I am creating a XML document which opens fine in IE. Implies MSXML
thinks it is a well formed document.
But when I try to load this document in VB.net using the following
code
Dim doc As New XmlDocument
doc.Load("C:\Projects\SQLXML\corc.xml")

I get the following error:

"System.Xml.XmlException: An unexpected end of file parsing CDATA has
occurred. Line 6, position 1.

That means you've got 0 (character with code 0) in the document. XML
spec doesn't allow characters with code less than x20 (except x9, xA,
xD) to be used within XML documents.

--
Oleg Tkachenko [XML MVP, XmlInsider]
http://blog.tkachenko.com
Nov 12 '05 #2
Oleg

Thanks for your response Oleg. But that doesn't seem to answer my
question. If there is a invalid character why doen't IE give me an
error.
Here is the query that I am using to create this doc. How do I fix
this error?
The data I am enclosing in the CData sections is RTF data.

Thanks
<?xml version="1.0" encoding="utf-8" ?>
<corc xmlns:sql="urn:schemas-microsoft-com:xml-sql"
xmlns="http://tempuri.org/corc.xsd">
<sql:query>
SELECT 1 as tag,
null as parent,
projectID as [item!1!projectID],
JIFRANumber as [item!1!JIFNumber!element],
Title as [item!1!Title!element],
[Group] as [item!1!Group!element],
Category as [item!1!Category!element],
'&lt;![CDATA['+scoutDescription+']]&gt;' as [item!1!Description!xml],
scoutImageFileName as [item!1!ImageFileName!element],
scoutFeaturedItem as [item!1!scoutFeaturedItem!element],
null as [Audience!2!AudienceID!element],
null as [Audience!2!AudienceValue!element],
null as [Characterictic!3!CharacteristicID!element],
null as [Characterictic!3!CharactericticValue!element]
FROM vwScoutCORCItems

UNION ALL

SELECT 2,
1,
vwScoutCORCItems.projectID,
vwScoutCORCItems.JIFRANumber,
vwScoutCORCItems.Title,
vwScoutCORCItems.[Group],
vwScoutCORCItems.Category,
'&lt;![CDATA[' + vwScoutCORCItems.scoutDescription+']]&gt;' ,
vwScoutCORCItems.scoutImageFileName,
vwScoutCORCItems.scoutFeaturedItem,
SCOUT_ITEM_AUDIENCE.AudienceID,
SCOUT_AUDIENCE.AudienceValue,
null,
null
FROM SCOUT_ITEM_AUDIENCE
INNER JOIN SCOUT_AUDIENCE ON SCOUT_ITEM_AUDIENCE.AudienceID =
SCOUT_AUDIENCE.AudienceID
INNER JOIN vwScoutCORCItems ON SCOUT_ITEM_AUDIENCE.ItemID =
vwScoutCORCItems.projectID

UNION ALL

SELECT 3,
1,
vwScoutCORCItems.projectID,
vwScoutCORCItems.JIFRANumber,
vwScoutCORCItems.Title,
vwScoutCORCItems.[Group],
vwScoutCORCItems.Category,
'&lt;![CDATA['+vwScoutCORCItems.scoutDescription+']]&gt;' ,
vwScoutCORCItems.scoutImageFileName,
vwScoutCORCItems.scoutFeaturedItem,
NULL,
NULL,
SCOUT_WORD.ScoutWordID,
SCOUT_WORD.Word
FROM SCOUT_ITEMCHARACTERISTIC
INNER JOIN vwScoutCORCItems ON SCOUT_ITEMCHARACTERISTIC.ItemID =
vwScoutCORCItems.projectID
INNER JOIN SCOUT_WORD ON
SCOUT_ITEMCHARACTERISTIC.ScoutCharacteristicID =
SCOUT_WORD.ScoutWordID

Order by [item!1!projectID],[Audience!2!AudienceID!element]

for xml explicit

</sql:query>

</corc>

That means you've got 0 (character with code 0) in the document. XML
spec doesn't allow characters with code less than x20 (except x9, xA,
xD) to be used within XML documents.

Nov 12 '05 #3
Oleg

Thanks for your response Oleg. But that doesn't seem to answer my
question. If there is a invalid character why doen't IE give me an
error.
Here is the query that I am using to create this doc. How do I fix
this error?
The data I am enclosing in the CData sections is RTF data.

Thanks
<?xml version="1.0" encoding="utf-8" ?>
<corc xmlns:sql="urn:schemas-microsoft-com:xml-sql"
xmlns="http://tempuri.org/corc.xsd">
<sql:query>
SELECT 1 as tag,
null as parent,
projectID as [item!1!projectID],
JIFRANumber as [item!1!JIFNumber!element],
Title as [item!1!Title!element],
[Group] as [item!1!Group!element],
Category as [item!1!Category!element],
'&lt;![CDATA['+scoutDescription+']]&gt;' as [item!1!Description!xml],
scoutImageFileName as [item!1!ImageFileName!element],
scoutFeaturedItem as [item!1!scoutFeaturedItem!element],
null as [Audience!2!AudienceID!element],
null as [Audience!2!AudienceValue!element],
null as [Characterictic!3!CharacteristicID!element],
null as [Characterictic!3!CharactericticValue!element]
FROM vwScoutCORCItems

UNION ALL

SELECT 2,
1,
vwScoutCORCItems.projectID,
vwScoutCORCItems.JIFRANumber,
vwScoutCORCItems.Title,
vwScoutCORCItems.[Group],
vwScoutCORCItems.Category,
'&lt;![CDATA[' + vwScoutCORCItems.scoutDescription+']]&gt;' ,
vwScoutCORCItems.scoutImageFileName,
vwScoutCORCItems.scoutFeaturedItem,
SCOUT_ITEM_AUDIENCE.AudienceID,
SCOUT_AUDIENCE.AudienceValue,
null,
null
FROM SCOUT_ITEM_AUDIENCE
INNER JOIN SCOUT_AUDIENCE ON SCOUT_ITEM_AUDIENCE.AudienceID =
SCOUT_AUDIENCE.AudienceID
INNER JOIN vwScoutCORCItems ON SCOUT_ITEM_AUDIENCE.ItemID =
vwScoutCORCItems.projectID

UNION ALL

SELECT 3,
1,
vwScoutCORCItems.projectID,
vwScoutCORCItems.JIFRANumber,
vwScoutCORCItems.Title,
vwScoutCORCItems.[Group],
vwScoutCORCItems.Category,
'&lt;![CDATA['+vwScoutCORCItems.scoutDescription+']]&gt;' ,
vwScoutCORCItems.scoutImageFileName,
vwScoutCORCItems.scoutFeaturedItem,
NULL,
NULL,
SCOUT_WORD.ScoutWordID,
SCOUT_WORD.Word
FROM SCOUT_ITEMCHARACTERISTIC
INNER JOIN vwScoutCORCItems ON SCOUT_ITEMCHARACTERISTIC.ItemID =
vwScoutCORCItems.projectID
INNER JOIN SCOUT_WORD ON
SCOUT_ITEMCHARACTERISTIC.ScoutCharacteristicID =
SCOUT_WORD.ScoutWordID

Order by [item!1!projectID],[Audience!2!AudienceID!element]

for xml explicit

</sql:query>

</corc>

That means you've got 0 (character with code 0) in the document. XML
spec doesn't allow characters with code less than x20 (except x9, xA,
xD) to be used within XML documents.

Nov 12 '05 #4
sunil wrote:
Thanks for your response Oleg. But that doesn't seem to answer my
question. If there is a invalid character why doen't IE give me an
error.

IE is kinda lax on this stuff. Try mozilla to see where you've got
forbidden chracters.
--
Oleg Tkachenko [XML MVP, XmlInsider]
http://blog.tkachenko.com
Nov 12 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

By using this site, you agree to our Privacy Policy and Terms of Use.