Solved

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

Posted on 2011-03-09
2
2,090 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
  • 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

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
sql query help 15 51
Wordpress Hacked 1 70
CURL sending XML without spaces PHP 5 30
Selenium and Xpath 4 29
Naughty Me. While I was changing the database name from DB1 to DB_PROD1 (yep it's not real database name ^v^), I changed the database name and notified my application fellows that I did it. They turn on the application, and everything is working. A …
Browsing the questions asked to the Experts of this forum, you will be amazed to see how many times people are headaching about monster regular expressions (regex) to select that specific part of some HTML or XML file they want to extract. The examp…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

762 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