Re: XML issue.



I can not pass it as a varchar because the max is 8000 i believe, and
my xml file is too large for this. My solution should be as simple as
I have my xml stored into a string prior to it being sent to my stored
procedure, I should just be able to do something like find the int a =
string.indexof( <?xml> > version="1.0" encoding="utf-8" ?>) then find
the length of it then delete it from the string. but i dont know what
to do after finding the index.

Erland Sommarskog wrote:
rhaazy (rhaazy@xxxxxxxxx) writes:
using ms sql 2000

EXEC sp_xml_preparedocument @iTree OUTPUT, @doc

I get an error unless I remove the encoding attribute(<?xml
version="1.0" encoding="utf-8" ?>) from my XML document prior to
running my stored procedure. So I need a way to strip this out via my
C# code that prepares the output.

I'm not really sure what the question is. If you want C# assistence, this
is not the best place.

Then again, OPENXML is perfectly able to handle UTF-8, but you must of
course pass the XML string as UTF-8. Specifically, you need to pass it
as a varchar value.

Try this example (which is posted in Latin-1, and should be handled as
Latin-1):

DECLARE @idoc int
DECLARE @doc varchar(1000)
SET @doc = '<?xml version="1.0" encoding="utf-8" ?>
<ROOT>
<Customers CustomerID="VINET" ContactName=""Räksmörgåis">
</Customers>
</ROOT>'
--Create an internal representation of the XML document.
EXEC sp_xml_preparedocument @idoc OUTPUT, @doc
-- SELECT statement that uses the OPENXML rowset provider.
SELECT *
FROM OPENXML (@idoc, '/ROOT/Customers')
EXEC sp_xml_removedocument @idoc


--
Erland Sommarskog, SQL Server MVP, esquel@xxxxxxxxxxxxx

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx

.



Relevant Pages

  • Re: Weird ADO error, any ideas?
    ... If the field causing the trouble is varchar, it doesn't seem someone would store extended ascii characters there, and it may be that what got into that field are remains of the connector and processor errors of the XML feed. ...
    (microsoft.public.vb.general.discussion)
  • Re: how to insert xml into sql 2005
    ... For right now I just know I have to get this into the sql database. ... to the contents of a SQL Server database. ... to XML processing no matter how big the XML document is. ... ,captionnohtml varchar 'CaptionNoHTML' ...
    (microsoft.public.sqlserver.xml)
  • Re: how to insert xml into sql 2005
    ... For right now I just know I have to get this into the sql database. ... to XML processing no matter how big the XML document is. ... ,captionnohtml varchar 'CaptionNoHTML' ...
    (microsoft.public.sqlserver.xml)
  • Re: nvarchar max
    ... Yes, SQL FTS supports char, nchar, varchar, nvarchar, varchar, ... nvarchar, image, varbinary and xml. ...
    (microsoft.public.sqlserver.fulltext)
  • Re: how to insert xml into sql 2005
    ... For right now I just know I have to get this into the sql database. ... The second one is how can I automation the xml import ever evening. ... ,captionnohtml varchar 'CaptionNoHTML' ... ,options varchar 'Options' ...
    (microsoft.public.sqlserver.xml)

Loading