473,387 Members | 1,619 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

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 29155

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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Korivo | last post by:
Im getting this error while trying to read a xml file that i receive from a POST heres the code: Dim MyXmlReader As XmlTextReader Dim strNodeResult As String Dim NodeType As XmlNodeType Dim...
1
by: Alan Wang | last post by:
Hi there, I got this message ("The data at the root level is invalid. Line 1, position 1.") when I moved the application from my workstation to Windows 2003 web server. But the wired thing the...
9
by: MR | last post by:
I get the following Exception "The data at the root level is invalid. Line 1, position 642" whenever I try to deserialize an incoming SOAP message. The incoming message is formed well and its...
0
by: XML newbie: Urgent pls help! | last post by:
I am using VB.Net. Asset List is a long array of AssetIds. I declare it as: Dim AssetList(0) As Long AssetList(0) = 47288 Now, I pass an array of AssetIDs as long from here into the...
2
by: =?Utf-8?B?am1ncm8=?= | last post by:
I created a web service in visual studio 2003, tested it with a sample.xml file from a vendor we are using, and it worked exactly like it should. I depoloyed it to our server, created a project...
1
by: paulnamroud | last post by:
Hi all, I wrote a stored procedure with ms sql 2005 which returns a string parameter. This parameter contains differents xml elements and it's well formated. First, its works fine when i call...
4
by: johnsonkt | last post by:
hi all , when m trying to validate my xml using xsd file it gives me the following error "Data at the root level is invalid. Line 1, position 1" i tried to open the XML file using IE and there...
1
by: ayemyat | last post by:
Hi All, I have a remoting service which consumes the web service in another server. I have the following exception throw by the web service. System.Xml.XmlException: The data at the root level...
2
by: Cirene | last post by:
My ASP.NET project builds fine (VS2008). I added a new web deployment project. When I try to build it I get: Data at the root level is invalid. Line1, position 1. (The file is web.config,...
3
by: Hamayun Khan | last post by:
Hi I get the following error Server Error in '/teachnetwork' Application. -------------------------------------------------------------------------------- Parser Error Description: An...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.