Solved

XML parsing: line 2, character 6, text/xmldecl not at the beginning of input

Posted on 2010-09-13
1
4,374 Views
Last Modified: 2012-08-13
Hi,

I am trying to create xml schema collection as follow:
use xmltest

create xml schema collection dbo.xmlProjectSchemaCollection as
'
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="project">
      <xs:complexType>
       <xs:sequence>
      <xs:element name="projectnumber" type="xs:int"/>
      <xs:element name="projectname" type="xs:string"/>
      <xs:element name="startdate" type="xs:date"/>
      <xs:element name="enddate" type="xs:date"/>
      <xs:element name="manager" type="xs:string"/>
      <xs:element name="scope" type="xs:string"/>
       </xs:sequence>
      </xs:complexType>
</xs:element>
</xs:schema>
'
However I am getting the following error when I executed the code above:
XML parsing: line 2, character 6, text/xmldecl not at the beginning of input

Why am I getting this error?   Could you please tell me how to fix?

Thanks~
0
Comment
Question by:IzzyTwinkly
1 Comment
 
LVL 5

Accepted Solution

by:
David Christal CISSP earned 500 total points
ID: 33668493
try this:

create xml schema collection dbo.xmlProjectSchemaCollection as
'<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="project">
<xs:complexType>
<xs:sequence>
<xs:element name="projectnumber" type="xs:int"/>
<xs:element name="projectname" type="xs:string"/>
<xs:element name="startdate" type="xs:date"/>
<xs:element name="enddate" type="xs:date"/>
<xs:element name="manager" type="xs:string"/>
<xs:element name="scope" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>'
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

In this article I will describe the Backup & Restore method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now