473,225 Members | 1,275 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,225 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 29149

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: veera ravala | last post by:
ServiceNow is a powerful cloud-based platform that offers a wide range of services to help organizations manage their workflows, operations, and IT services more efficiently. At its core, ServiceNow...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
2
by: jimatqsi | last post by:
The boss wants the word "CONFIDENTIAL" overlaying certain reports. He wants it large, slanted across the page, on every page, very light gray, outlined letters, not block letters. I thought Word Art...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....

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.