【发布时间】:2023-04-04 23:05:01
【问题描述】:
我正在尝试解析从 web 服务获得的 xml 信息,以便稍后放入表中。 我只有一个空字段没有错误,所以我可能忽略了一些小东西,有人能把我推向正确的方向吗?
Declare @myXml as xml;
set @myXml = '<?xml version="1.0" encoding="UTF-8"?>
<string xmlns="http://www.webserviceX.NET">
<CurrentWeather>
<Location>Eindhoven, Netherlands (EHEH) 51-27N 005-25E 28M</Location>
<Time>Jun 15, 2016 - 06:55 AM EDT / 2016.06.15 1055 UTC</Time>
<Wind>from the WSW (240 degrees) at 2 MPH (2 KT):0</Wind>
<Visibility>greater than 7 mile(s):0</Visibility>
<SkyConditions>mostly cloudy</SkyConditions>
<Temperature>62 F (17 C)</Temperature>
<DewPoint>57 F (14 C)</DewPoint>
<RelativeHumidity>82%</RelativeHumidity>
<Pressure>29.50 in. Hg (0999 hPa)</Pressure>
<Status>Success</Status>
</CurrentWeather>
</string>';
SELECT
b.value('(./CurrentWeather/Location/text())[1]','Varchar(250)') as [Location]
FROM @myXml.nodes('/string') as a(b);
【问题讨论】:
-
TSQL XML FUNCTION的可能重复
标签: sql-server xml tsql