关于xml字段的Xquery查询问题,已经困惑很多天了
时间:2011-12-06
来源:互联网
XML code
有以上的xml字段,字段名为F_xml,表名table,我想列出<titleTsxm 节的值,也就是'XORTISING-X ACHINE'的内容
写了
SQL code
但总是报错tsip不是命名空间,请教高手该怎么取出<titleTsxm 节的内容??
<tsip:dataFeed xmlns="http://schemas.thomson.com/ts/20041221/tsip" xmlns:tsip="http://schemas.thomson.com/ts/20041221/tsip" xmlns:dwpi="http://schemas.thomson.com/ts/20041221/dwpi" xmlns:wila="http://schemas.thomson.com/ts/20041221/wila" xmlns:tsxm="http://schemas.thomson.com/ts/20041221/tsxm" xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:cals="http://CALS-URI" xmlns:xhtml="http://www.w3.org/1999/xhtml" tsip:dtdVersion="22" tsip:date="2011-08-22"> <tsip tsip:dtdVersion="22" tsip:date="2011-06-16" tsip:action="new"> <memberPatents> <patent tsip:action="new" tsip:cc="US" tsip:se="0000024" tsip:ki="A"> <accessions tsip:action="new"> <accession tsip:src="wila" tsip:type="key">US-24-A</accession> <accession tsip:src="tscm" tsip:type="tscmKey">US-24-A-18360914</accession> </accessions> <updates tsip:action="new"> <update tsip:src="wila" tsip:type="pubw">183637</update> <update tsip:src="wila" tsip:type="uw">183637</update> </updates> <publications tsip:action="new"> <publication tsip:lang="en"> <documentId> <number tsip:form="wila">0000024</number> <number tsip:form="original">00000024</number> <number tsip:form="tsip">0000024</number> <countryCode>US</countryCode> <kindCode>A</kindCode> <date>1836-09-14</date> </documentId> <publicationFirst> <date>1836-09-14</date> </publicationFirst> <patentDate tsip:no="1"> <date>1836-09-14</date> </patentDate> </publication> </publications> <metaData tsip:action="new"> <patentCounts tsip:publicationCount="1" tsip:countryCount="1" /> <documentFlag>CLMEN, DSCREN, ICMX, INX, PAX, PS, USP</documentFlag> </metaData> <classificationUsCurrent tsip:action="new"> <uspc tsip:type="main"> <mainclass>144</mainclass> <subclass>075000</subclass> </uspc> </classificationUsCurrent> <classificationUs tsip:action="new"> <uspc tsip:type="main"> <mainclass>144</mainclass> <subclass>075000</subclass> </uspc> </classificationUs> <titles tsip:action="new"> <titleTsxm tsip:lang="en" tsip:input="original">XORTISING-X ACHINE</titleTsxm> </titles> <claimed tsip:action="new"> <claimsTsxm tsip:lang="en"> <claimsTextTsxm> <tsxm:p tsxm:align="left">U.NITED STATES PATENT OFFICE.</tsxm:p> </claimsTextTsxm> </claimsTsxm> </claimed> <descriptionsOriginal tsip:action="new"> <descriptionOriginalTsxm tsip:lang="en"> <detailedDescriptionTsxm> <tsxm:p tsxm:align="left">HARVEY HYDE,</tsxm:p> <tsxm:p tsxm:align="left">BATHSHEBA Mr,,TCALr.</tsxm:p> </detailedDescriptionTsxm> </descriptionOriginalTsxm> </descriptionsOriginal> </patent> </memberPatents> </tsip> </tsip:dataFeed>
有以上的xml字段,字段名为F_xml,表名table,我想列出<titleTsxm 节的值,也就是'XORTISING-X ACHINE'的内容
写了
SQL code
SELECT [f_xml].value('(/tsip:dataFeed/tsip/memberPatents/patent/titles/titleTsxm)[1]' ,'nvarchar(max)') FROM table
但总是报错tsip不是命名空间,请教高手该怎么取出<titleTsxm 节的内容??
作者: wstar 发布时间: 2011-12-06
命令空间都没声明
作者: liangCK 发布时间: 2011-12-06
SQL code
DECLARE @x xml; SET @x='<tsip:dataFeed xmlns="http://schemas.thomson.com/ts/20041221/tsip" xmlns:tsip="http://schemas.thomson.com/ts/20041221/tsip" xmlns:dwpi="http://schemas.thomson.com/ts/20041221/dwpi" xmlns:wila="http://schemas.thomson.com/ts/20041221/wila" xmlns:tsxm="http://schemas.thomson.com/ts/20041221/tsxm" xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:cals="http://CALS-URI" xmlns:xhtml="http://www.w3.org/1999/xhtml" tsip:dtdVersion="22" tsip:date="2011-08-22"> <tsip tsip:dtdVersion="22" tsip:date="2011-06-16" tsip:action="new"> <memberPatents> <patent tsip:action="new" tsip:cc="US" tsip:se="0000024" tsip:ki="A"> <accessions tsip:action="new"> <accession tsip:src="wila" tsip:type="key">US-24-A</accession> <accession tsip:src="tscm" tsip:type="tscmKey">US-24-A-18360914</accession> </accessions> <updates tsip:action="new"> <update tsip:src="wila" tsip:type="pubw">183637</update> <update tsip:src="wila" tsip:type="uw">183637</update> </updates> <publications tsip:action="new"> <publication tsip:lang="en"> <documentId> <number tsip:form="wila">0000024</number> <number tsip:form="original">00000024</number> <number tsip:form="tsip">0000024</number> <countryCode>US</countryCode> <kindCode>A</kindCode> <date>1836-09-14</date> </documentId> <publicationFirst> <date>1836-09-14</date> </publicationFirst> <patentDate tsip:no="1"> <date>1836-09-14</date> </patentDate> </publication> </publications> <metaData tsip:action="new"> <patentCounts tsip:publicationCount="1" tsip:countryCount="1" /> <documentFlag>CLMEN, DSCREN, ICMX, INX, PAX, PS, USP</documentFlag> </metaData> <classificationUsCurrent tsip:action="new"> <uspc tsip:type="main"> <mainclass>144</mainclass> <subclass>075000</subclass> </uspc> </classificationUsCurrent> <classificationUs tsip:action="new"> <uspc tsip:type="main"> <mainclass>144</mainclass> <subclass>075000</subclass> </uspc> </classificationUs> <titles tsip:action="new"> <titleTsxm tsip:lang="en" tsip:input="original">XORTISING-X ACHINE</titleTsxm> </titles> <claimed tsip:action="new"> <claimsTsxm tsip:lang="en"> <claimsTextTsxm> <tsxm:p tsxm:align="left">U.NITED STATES PATENT OFFICE.</tsxm:p> </claimsTextTsxm> </claimsTsxm> </claimed> <descriptionsOriginal tsip:action="new"> <descriptionOriginalTsxm tsip:lang="en"> <detailedDescriptionTsxm> <tsxm:p tsxm:align="left">HARVEY HYDE,</tsxm:p> <tsxm:p tsxm:align="left">BATHSHEBA Mr,,TCALr.</tsxm:p> </detailedDescriptionTsxm> </descriptionOriginalTsxm> </descriptionsOriginal> </patent> </memberPatents> </tsip> </tsip:dataFeed>' --<tsip:dataFeed xmlns="http://schemas.thomson.com/ts/20041221/tsip" xmlns:tsip="http://schemas.thomson.com/ts/20041221/tsip" xmlns:dwpi="http://schemas.thomson.com/ts/20041221/dwpi" xmlns:wila="http://schemas.thomson.com/ts/20041221/wila" xmlns:tsxm="http://schemas.thomson.com/ts/20041221/tsxm" xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:cals="http://CALS-URI" xmlns:xhtml="http://www.w3.org/1999/xhtml" tsip:dtdVersion="22" tsip:date="2011-08-22"> ;WITH XMLNAMESPACES ( DEFAULT 'http://schemas.thomson.com/ts/20041221/tsip', 'http://schemas.thomson.com/ts/20041221/tsip' AS tsip, 'http://schemas.thomson.com/ts/20041221/dwpi' AS dwpi, 'http://schemas.thomson.com/ts/20041221/wila' AS wila, 'http://schemas.thomson.com/ts/20041221/tsxm' AS tsxm, 'http://www.w3.org/1998/Math/MathML' AS mml, 'http://CALS-URI' AS cals, 'http://www.w3.org/1999/xhtml' AS xhtml ) SELECT @x.value('(/tsip:dataFeed/tsip/memberPatents/patent/titles/titleTsxm)[1]' ,'nvarchar(max)') /* -------------------------------------------------- XORTISING-X ACHINE (1 行受影响) */
作者: liangCK 发布时间: 2011-12-06
SQL code
DECLARE @x xml; SET @x='<tsip:dataFeed xmlns="http://schemas.thomson.com/ts/20041221/tsip" xmlns:tsip="http://schemas.thomson.com/ts/20041221/tsip" xmlns:dwpi="http://schemas.thomson.com/ts/20041221/dwpi" xmlns:wila="http://schemas.thomson.com/ts/20041221/wila" xmlns:tsxm="http://schemas.thomson.com/ts/20041221/tsxm" xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:cals="http://CALS-URI" xmlns:xhtml="http://www.w3.org/1999/xhtml" tsip:dtdVersion="22" tsip:date="2011-08-22"> <tsip tsip:dtdVersion="22" tsip:date="2011-06-16" tsip:action="new"> <memberPatents> <patent tsip:action="new" tsip:cc="US" tsip:se="0000024" tsip:ki="A"> <accessions tsip:action="new"> <accession tsip:src="wila" tsip:type="key">US-24-A</accession> <accession tsip:src="tscm" tsip:type="tscmKey">US-24-A-18360914</accession> </accessions> <updates tsip:action="new"> <update tsip:src="wila" tsip:type="pubw">183637</update> <update tsip:src="wila" tsip:type="uw">183637</update> </updates> <publications tsip:action="new"> <publication tsip:lang="en"> <documentId> <number tsip:form="wila">0000024</number> <number tsip:form="original">00000024</number> <number tsip:form="tsip">0000024</number> <countryCode>US</countryCode> <kindCode>A</kindCode> <date>1836-09-14</date> </documentId> <publicationFirst> <date>1836-09-14</date> </publicationFirst> <patentDate tsip:no="1"> <date>1836-09-14</date> </patentDate> </publication> </publications> <metaData tsip:action="new"> <patentCounts tsip:publicationCount="1" tsip:countryCount="1" /> <documentFlag>CLMEN, DSCREN, ICMX, INX, PAX, PS, USP</documentFlag> </metaData> <classificationUsCurrent tsip:action="new"> <uspc tsip:type="main"> <mainclass>144</mainclass> <subclass>075000</subclass> </uspc> </classificationUsCurrent> <classificationUs tsip:action="new"> <uspc tsip:type="main"> <mainclass>144</mainclass> <subclass>075000</subclass> </uspc> </classificationUs> <titles tsip:action="new"> <titleTsxm tsip:lang="en" tsip:input="original">XORTISING-X ACHINE</titleTsxm> </titles> <claimed tsip:action="new"> <claimsTsxm tsip:lang="en"> <claimsTextTsxm> <tsxm:p tsxm:align="left">U.NITED STATES PATENT OFFICE.</tsxm:p> </claimsTextTsxm> </claimsTsxm> </claimed> <descriptionsOriginal tsip:action="new"> <descriptionOriginalTsxm tsip:lang="en"> <detailedDescriptionTsxm> <tsxm:p tsxm:align="left">HARVEY HYDE,</tsxm:p> <tsxm:p tsxm:align="left">BATHSHEBA Mr,,TCALr.</tsxm:p> </detailedDescriptionTsxm> </descriptionOriginalTsxm> </descriptionsOriginal> </patent> </memberPatents> </tsip> </tsip:dataFeed>' --<tsip:dataFeed xmlns="http://schemas.thomson.com/ts/20041221/tsip" xmlns:tsip="http://schemas.thomson.com/ts/20041221/tsip" xmlns:dwpi="http://schemas.thomson.com/ts/20041221/dwpi" xmlns:wila="http://schemas.thomson.com/ts/20041221/wila" xmlns:tsxm="http://schemas.thomson.com/ts/20041221/tsxm" xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:cals="http://CALS-URI" xmlns:xhtml="http://www.w3.org/1999/xhtml" tsip:dtdVersion="22" tsip:date="2011-08-22"> SELECT @x.value(' declare default element namespace "http://schemas.thomson.com/ts/20041221/tsip"; declare namespace tsip = "http://schemas.thomson.com/ts/20041221/tsip"; declare namespace dwpi = "http://schemas.thomson.com/ts/20041221/dwpi"; declare namespace wila = "http://schemas.thomson.com/ts/20041221/wila"; declare namespace tsxm = "http://schemas.thomson.com/ts/20041221/tsxm"; declare namespace mml = "http://www.w3.org/1998/Math/MathML"; declare namespace cals = "http://CALS-URI"; declare namespace xhtml = "http://www.w3.org/1999/xhtml"; (/tsip:dataFeed/tsip/memberPatents/patent/titles/titleTsxm)[1]' ,'nvarchar(MAX)') /* -------------------------------------------------- XORTISING-X ACHINE (1 行受影响) */
作者: liangCK 发布时间: 2011-12-06
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28