English 中文(简体)
SQL Server 2008: SQLXML Query function .query( //mypath/text() ) doesn t XML decode
原标题:

In Microsoft SQL Server 2008, when executing .query( {xpath}/text() ) on an XML stream column value, if the value of the XPath selected node contains "&", the return value is "&amp" instead of "&".

Is this a bug, or am I doing something wrong? Or rather, how do I get the unencoded text, i.e. equivalent of .innerText (per W3C XML DOM), with SQLXML XPath if text() in the XPath query isn t supposed to do that?

最佳回答

No bug, SQL XML decodes XML escape sequences correctly:

declare @x xml;
set @x =  <node>&amp;some</node> ;
select @x.value(N (node)[1] , N varchar(max) );

What most likely is your problem is a misunderstanding on your part of the XML query method: it returns an XML fragment, and as such all content will be... escaped, since it s XML:

declare @x xml;
set @x =  <node>&amp;some</node> ;
select @x.query(N /node/text() );
问题回答

暂无回答




相关问题
Export tables from SQL Server to be imported to Oracle 10g

I m trying to export some tables from SQL Server 2005 and then create those tables and populate them in Oracle. I have about 10 tables, varying from 4 columns up to 25. I m not using any constraints/...

SQL server: Can NT accounts be mapped to SQL server accounts

In our database we have an SQL server account that has the correct roles to access some of the databases. We are now switching to windows authentication and I was wondering if we can create a NT user ...

SQL Server 2000, ADO 2.8, VB6

How to determine if a Transaction is active i.e. before issuing Begin Transaction I want to ensure that no previous transaction are open.. the platform is VB6, MS-SQL Server 2000 and ADO 2.8

热门标签