我想查询publish根节点下的body节点的内容,我的sql如下DECLARE @xml XML
SET @xml='<Publish xmlns="http://soa.com/SOA/USA/InfrastructureService/V30/PubSubService">
<RouteTable>
<Article>
<ArticleCategory>RMANotification</ArticleCategory>
<ArticleType1>Sync</ArticleType1>
<ArticleType2>IPPToWCQX</ArticleType2>
</Article>
</RouteTable>
<Node>
<MessageHead>
<Action>Notify</Action>
<Type>RMA</Type>
<CompanyCode>123456789</CompanyCode>
<FromSystem>IPP</FromSystem>
<ToSystem>WCQX</ToSystem>
</MessageHead>
<Body>
<ChannelRMA>
<Version>1.0</Version>
<AppKey>90000001</AppKey>
<Method />
<Session />
<TimeStamp />
<RMAID>85411254</RMAID>
<RMARefundAmount>100.00</RMARefundAmount>
<RMAItems>
<RMAItem>
<RMAItemID>123456</RMAItemID>
<ProcessType>Refund</ProcessType>
</RMAItem>
<RMAItem>
<RMAItemID>123457</RMAItemID>
<ProcessType>Return</ProcessType>
</RMAItem>
</RMAItems>
</ChannelRMA>
</Body>
</Node>
</Publish>'
;WITH XMLNAMESPACES (DEFAULT 'http://soa.com/SOA/USA/InfrastructureService/V30/PubSubService')
SELECT @xml.query('(/Publish/Node/Body/ChannelRMA)[1]')
但是查出来的xml就变成了下面这样:
<p1:ChannelRMA xmlns:p1="http://soa.com/SOA/USA/InfrastructureService/V30/PubSubService">
<p1:Version>1.0</p1:Version>
<p1:AppKey>90000001</p1:AppKey>
<p1:Method />
<p1:Session />
<p1:TimeStamp />
<p1:RMAID>85411254</p1:RMAID>
<p1:RMARefundAmount>100.00</p1:RMARefundAmount>
<p1:RMAItems>
<p1:RMAItem>
<p1:RMAItemID>123456</p1:RMAItemID>
<p1:ProcessType>Refund</p1:ProcessType>
</p1:RMAItem>
<p1:RMAItem>
<p1:RMAItemID>123457</p1:RMAItemID>
<p1:ProcessType>Return</p1:ProcessType>
</p1:RMAItem>
</p1:RMAItems>
</p1:ChannelRMA>
怎么自动加了个p1的标签还有namespace,怎么才能让查出来的结果是下面这样呢: <ChannelRMA>
<Version>1.0</Version>
<AppKey>90000001</AppKey>
<Method />
<Session />
<TimeStamp />
<RMAID>85411254</RMAID>
<RMARefundAmount>100.00</RMARefundAmount>
<RMAItems>
<RMAItem>
<RMAItemID>123456</RMAItemID>
<ProcessType>Refund</ProcessType>
</RMAItem>
<RMAItem>
<RMAItemID>123457</RMAItemID>
<ProcessType>Return</ProcessType>
</RMAItem>
</RMAItems>
</ChannelRMA>
SET @xml='<Publish xmlns="http://soa.com/SOA/USA/InfrastructureService/V30/PubSubService">
<RouteTable>
<Article>
<ArticleCategory>RMANotification</ArticleCategory>
<ArticleType1>Sync</ArticleType1>
<ArticleType2>IPPToWCQX</ArticleType2>
</Article>
</RouteTable>
<Node>
<MessageHead>
<Action>Notify</Action>
<Type>RMA</Type>
<CompanyCode>123456789</CompanyCode>
<FromSystem>IPP</FromSystem>
<ToSystem>WCQX</ToSystem>
</MessageHead>
<Body>
<ChannelRMA>
<Version>1.0</Version>
<AppKey>90000001</AppKey>
<Method />
<Session />
<TimeStamp />
<RMAID>85411254</RMAID>
<RMARefundAmount>100.00</RMARefundAmount>
<RMAItems>
<RMAItem>
<RMAItemID>123456</RMAItemID>
<ProcessType>Refund</ProcessType>
</RMAItem>
<RMAItem>
<RMAItemID>123457</RMAItemID>
<ProcessType>Return</ProcessType>
</RMAItem>
</RMAItems>
</ChannelRMA>
</Body>
</Node>
</Publish>'
;WITH XMLNAMESPACES (DEFAULT 'http://soa.com/SOA/USA/InfrastructureService/V30/PubSubService')
SELECT @xml.query('(/Publish/Node/Body/ChannelRMA)[1]')
但是查出来的xml就变成了下面这样:
<p1:ChannelRMA xmlns:p1="http://soa.com/SOA/USA/InfrastructureService/V30/PubSubService">
<p1:Version>1.0</p1:Version>
<p1:AppKey>90000001</p1:AppKey>
<p1:Method />
<p1:Session />
<p1:TimeStamp />
<p1:RMAID>85411254</p1:RMAID>
<p1:RMARefundAmount>100.00</p1:RMARefundAmount>
<p1:RMAItems>
<p1:RMAItem>
<p1:RMAItemID>123456</p1:RMAItemID>
<p1:ProcessType>Refund</p1:ProcessType>
</p1:RMAItem>
<p1:RMAItem>
<p1:RMAItemID>123457</p1:RMAItemID>
<p1:ProcessType>Return</p1:ProcessType>
</p1:RMAItem>
</p1:RMAItems>
</p1:ChannelRMA>
怎么自动加了个p1的标签还有namespace,怎么才能让查出来的结果是下面这样呢: <ChannelRMA>
<Version>1.0</Version>
<AppKey>90000001</AppKey>
<Method />
<Session />
<TimeStamp />
<RMAID>85411254</RMAID>
<RMARefundAmount>100.00</RMARefundAmount>
<RMAItems>
<RMAItem>
<RMAItemID>123456</RMAItemID>
<ProcessType>Refund</ProcessType>
</RMAItem>
<RMAItem>
<RMAItemID>123457</RMAItemID>
<ProcessType>Return</ProcessType>
</RMAItem>
</RMAItems>
</ChannelRMA>
解决方案 »
- 刚提升的女部门经理给我几个文件,问我是什么数据库,我晕
- 请高手帮忙解释一下这句话的具体含义,要具体的
- update 中条件有多个表怎么办?
- 复合主键的问题
- 用sp_rename更改列名时,sql server 自动生成脚本为什么要分两次完成?
- 我想把一个数据库里的X表中的X1列的所有数据添加到·这个数据库中的Y表Y1列中·!~~
- sql两表间导数据,解决就给分?急
- 有一台机器sqlserver慢,其它正常,执行一条插入要30ms 正常低于1ms
- 大规模的数据,如何快速的写进数据库??急!!
- 不装ORACLE CLIENT用ODBC怎么连接?
- 求一合并更新SQL
- 幼儿园的课程表咋设计 完全没思路啊
DECLARE @xml XML
SET @xml='<Publish>
<RouteTable>
<Article>
<ArticleCategory>RMANotification</ArticleCategory>
<ArticleType1>Sync</ArticleType1>
<ArticleType2>IPPToWCQX</ArticleType2>
</Article>
</RouteTable>
<Node>
<MessageHead>
<Action>Notify</Action>
<Type>RMA</Type>
<CompanyCode>123456789</CompanyCode>
<FromSystem>IPP</FromSystem>
<ToSystem>WCQX</ToSystem>
</MessageHead>
<Body>
<ChannelRMA>
<Version>1.0</Version>
<AppKey>90000001</AppKey>
<Method />
<Session />
<TimeStamp />
<RMAID>85411254</RMAID>
<RMARefundAmount>100.00</RMARefundAmount>
<RMAItems>
<RMAItem>
<RMAItemID>123456</RMAItemID>
<ProcessType>Refund</ProcessType>
</RMAItem>
<RMAItem>
<RMAItemID>123457</RMAItemID>
<ProcessType>Return</ProcessType>
</RMAItem>
</RMAItems>
</ChannelRMA>
</Body>
</Node>
</Publish>'
--;WITH XMLNAMESPACES (DEFAULT 'http://soa.com/SOA/USA/InfrastructureService/V30/PubSubService')
SELECT @xml.query('(/Publish/Node/Body/ChannelRMA)[1]')
DECLARE @xml XML
SET @xml='
<Publish xmlns="http://soa.com/SOA/USA/InfrastructureService/V30/PubSubService">
<RouteTable>
<Article>
<ArticleCategory>RMANotification</ArticleCategory>
<ArticleType1>Sync</ArticleType1>
<ArticleType2>IPPToWCQX</ArticleType2>
</Article>
</RouteTable>
<Node>
<MessageHead>
<Action>Notify</Action>
<Type>RMA</Type>
<CompanyCode>123456789</CompanyCode>
<FromSystem>IPP</FromSystem>
<ToSystem>WCQX</ToSystem>
</MessageHead>
<Body>
<ChannelRMA>
<Version>1.0</Version>
<AppKey>90000001</AppKey>
<Method />
<Session />
<TimeStamp />
<RMAID>85411254</RMAID>
<RMARefundAmount>100.00</RMARefundAmount>
<RMAItems>
<RMAItem>
<RMAItemID>123456</RMAItemID>
<ProcessType>Refund</ProcessType>
</RMAItem>
<RMAItem>
<RMAItemID>123457</RMAItemID>
<ProcessType>Return</ProcessType>
</RMAItem>
</RMAItems>
</ChannelRMA>
</Body>
</Node>
</Publish>';
select @xml.query('
declare default element namespace "http://soa.com/SOA/USA/InfrastructureService/V30/PubSubService";
/Publish/Node/Body/ChannelRMA')/*
<ChannelRMA xmlns="http://soa.com/SOA/USA/InfrastructureService/V30/PubSubService">
<Version>1.0</Version>
<AppKey>90000001</AppKey>
<Method />
<Session />
<TimeStamp />
<RMAID>85411254</RMAID>
<RMARefundAmount>100.00</RMARefundAmount>
<RMAItems>
<RMAItem>
<RMAItemID>123456</RMAItemID>
<ProcessType>Refund</ProcessType>
</RMAItem>
<RMAItem>
<RMAItemID>123457</RMAItemID>
<ProcessType>Return</ProcessType>
</RMAItem>
</RMAItems>
</ChannelRMA>
*/