469,281 Members | 2,489 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

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

The data at the root level is invalid. Line 1, position 1

I pulling my hair out with is error!

I've used an external source to validate my schema against
the xml and it succeeds without any errors
(http://apps.gotdotnet.com/xmltools/x...tor/Default.as
px) but as soon as I run it through some code it pops up
with that error!

Here's my code:

// Create and setup XML
document
XmlTextWriter
xmlDiskWriter = new XmlTextWriter
(fullyQualifiedFilename,Encoding.UTF8);
xmlDiskWriter.Formatting =
Formatting.Indented; // For easier reading :)
xmlDiskWriter.Indentation
= 4; // Looks even nicer ...

xmlDiskWriter.WriteStartDocument();

// Transform
xslDoc.Transform
(xmlDoc,null,xmlDiskWriter,null);

// Validate CID
try
{

XmlReader xmlRead
= new XmlTextReader(location.ToOSString() + xsdCID);

XmlSchemaCollection xsdDoc = new
XmlSchemaCollection();

XmlValidatingReader xmlValid = new
XmlValidatingReader( xmlDiskWriter.ToString
(),XmlNodeType.Document, null);

xsdDoc.Add
(null,xmlRead);

xmlValid.Schemas.Add(xsdDoc);

// Add validation
event handler

xmlValid.ValidationType = ValidationType.Schema;

xmlValid.ValidationEventHandler += new
ValidationEventHandler(ValidationHandler);
xmlValid.MoveToContent();

while(xmlValid.Read
());
xmlValid.Close();

// Raise
exception, if XML validation fails
if (ErrorsCount >
0)
{
throw new
Exception(ErrorMessage);
}
}
catch(Exception error)
{
// XML Validation
failed
MessageBox.Show
("XML validation failed:" + error.Message, "Error",

MessageBoxButtons.OKCancel, MessageBoxIcon.Error);

}

Any idea's?
Nov 12 '05 #1
3 29019

Got the same problem over here !

I have a IE Web Controls Treviewcontrol filled with an at runtim
generated XML (generated from a database.) In my developmen
environment all is working fine. But in a release environment i
crashes with this error. (See attachment bmp)

Anybody any idea's ?
TX,
Don Wha

+----------------------------------------------------------------
| Attachment filename: error.png
|Download attachment: http://www.mcse.ms/attachment.php?postid=1827686
+----------------------------------------------------------------

-
Don Wha
-----------------------------------------------------------------------
Posted via http://www.mcse.m
-----------------------------------------------------------------------
View this thread: http://www.mcse.ms/message698013.htm

Nov 12 '05 #2
Deena wrote:
I pulling my hair out with is error!

I've used an external source to validate my schema against
the xml and it succeeds without any errors
(http://apps.gotdotnet.com/xmltools/x...tor/Default.as
px) but as soon as I run it through some code it pops up
with that error!


Generally speaking the error means the XML is malformed. Usually that
happens when remote resource appears to be text, not XML, or there is
some text just before root element tag. Make sure you've got well-formed
XML.
PS. Can it be security issue?
--
Oleg Tkachenko [XML MVP]
http://blog.tkachenko.com
Nov 12 '05 #3
Deena wrote:
I pulling my hair out with is error!

I've used an external source to validate my schema against
the xml and it succeeds without any errors
(http://apps.gotdotnet.com/xmltools/x...tor/Default.as
px) but as soon as I run it through some code it pops up
with that error!


Generally speaking the error means the XML is malformed. Usually that
happens when remote resource appears to be text, not XML, or there is
some text just before root element tag. Make sure you've got well-formed
XML.
PS. Can it be security issue?
--
Oleg Tkachenko [XML MVP]
http://blog.tkachenko.com
Nov 12 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by XML newbie: Urgent pls help! | last post: by
2 posts views Thread by =?Utf-8?B?am1ncm8=?= | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.