【发布时间】:2014-08-15 11:04:37
【问题描述】:
我正在使用 SQL Server 2008 R2 来解析 XML,但它没有返回任何结果:
<?xml version="1.0" encoding="UTF-8"?>
<ymaps xmlns="http://maps.yandex.ru/ymaps/1.x" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" http://maps.yandex.ru/business/1.x http://maps.yandex.ru/schemas/business/1.x/business.xsd http://maps.yandex.ru/geocoder/1.x http://maps.yandex.ru/schemas/geocoder/1.x/geocoder.xsd http://maps.yandex.ru/psearch/1.x http://maps.yandex.ru/schemas/psearch/1.x/psearch.xsd http://maps.yandex.ru/search/1.x http://maps.yandex.ru/schemas/search/1.x/search.xsd http://maps.yandex.ru/web/1.x http://maps.yandex.ru/schemas/web/1.x/web.xsd http://maps.yandex.ru/search/internal/1.x ../../search/internal/1.x/internal.xsd">
<Attribution xmlns="http://maps.yandex.ru/attribution/1.x" />
<GeoObjectCollection>
<featureMember xmlns="http://www.opengis.net/gml">
<GeoObject xmlns="http://maps.yandex.ru/ymaps/1.x">
<Point xmlns="http://www.opengis.net/gml">
<pos>47.248887 56.143900</pos>
</Point>
</GeoObject>
</featureMember>
</GeoObjectCollection>
</ymaps>
代码:
SELECT @XML.value('(/ymaps/GeoObjectCollection/featureMember/GeoObject/Point/pos) [1]', 'varchar(255)')
还有其他好的方法吗?谢谢。
【问题讨论】:
标签: sql-server xml sql-server-2008-r2 xquery