Solved

XML: The XML parse error 0xc00ce505 occurred on line number 3, near the XML text "

Posted on 2011-03-09
2
2,152 Views
Last Modified: 2012-05-11
i have this store procedure
create procedure usp_chk (@xmldoc nvarchar(100))
as

begin
      declare @hind int

      exec sp_xml_preparedocument @hind output, @xmldoc
      select *
      from openxml (@hind,'Root/Location/Item',2)
      with
            (
                  LocID int '../@LocID',
                  ItemID int,
                  ItemDesc varchar(50),
                  Qty int
            )
      exec sp_xml_removedocument @hind

end

when i test
--Testing
go
declare @xmldoc nvarchar(1000)
set @xmldoc = '<Root>
<Location LocationID="1" LocName="East Warehouse">
      <Item ItemID="22" ItemDesc="Keyboard" Qty="120">
      </Item>
      <Item ItemID="27" ItemDesc="Flat Screen" Qty="72">
      </Item>
</Location>
</Root>'

exec usp_chk  @xmldoc

i have this error
The XML parse error 0xc00ce505 occurred on line number 3, near the XML text "      <Item ItemID="22" ItemDesc="Keyboard" Q".
Msg 6602, Level 16, State 2, Procedure sp_xml_preparedocument, Line 1
The error description is 'A name contained an invalid character.'.
Msg 8179, Level 16, State 5, Procedure usp_chk, Line 7
Could not find prepared statement with handle 0.
Msg 6607, Level 16, State 3, Procedure sp_xml_removedocument, Line 1
sp_xml_removedocument: The value supplied for parameter number 1 is invalid.

0
Comment
Question by:enrique_aeo
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
2 Comments
 
LVL 75

Assisted Solution

by:käµfm³d 👽
käµfm³d   👽 earned 250 total points
ID: 35096058
In your sproc declaration, you did not make the incoming parameter large enough to accommodate the incoming XML string. You declared it to be 100 in size, but the string being sent in is larger than 100. Making this value larger (e.g. make it match the 1000 you defined for the test parameter) should resolve this.

You also have a couple of errors in your sproc logic. I believe you need to use "1" instead of "2" on your OPENXML call. Also, your selection for LocationID is incorrect. You put "@LocID", but it should be "@LocationID."
0
 
LVL 75

Accepted Solution

by:
käµfm³d   👽 earned 250 total points
ID: 35096098
Here's a demonstration:
untitled.PNG
0

Featured Post

[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

SQL Server engine let you use a Windows account or a SQL Server account to connect to a SQL Server instance. This can be configured immediatly during the SQL Server installation or after in the Server Authentication section in the Server properties …
In this article I will describe the Copy Database Wizard 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.
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

726 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