私がやろうとしているのは、電話番号を抽出し、電話番号ごとにレコードを作成することです:
[1] シングルトンのため、Used のレコードしか取得できません。
どんな助けでも大歓迎です。ありがとう
Department PhoneNumber
--------------------------
Used 866-605-1976
Parts 877-733-0759
BodyShop 877-733-0753
T-SQL コード:
DECLARE @Xml AS VARCHAR(MAX) = '<WidgetViewData>
<WidgetView>
<Data>
<widgetid>7LS5R48I2ZL5DET585H5</widgetid>
<widgettype>Dynamic</widgettype>
<partnerid>2</partnerid>
<cr_domain>target.dealer.com</cr_domain>
<cr_referrer>http://organic.search.com:8080/test/refer.jspx</cr_referrer>
<cr_url>http://target.dealer.com:8080/test/debugtest.jsp</cr_url>
<cr_href>http://target.dealer.com:8080/test/debugtest.jsp</cr_href>
<userhostaddress>127.0.0.1</userhostaddress>
<useragent>Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0)</useragent>
<cradmin>2013_08_02_1375489550401</cradmin>
<jsession>2013_08_02_1375505899038</jsession>
<anchorphonenumbers>
<anchorPhoneNumber>
<department>Used</department>
<phoneNumber>
<areaCode>866</areaCode>
<countryCode>1</countryCode>
<extension></extension>
<nanpa>605-1976</nanpa>
<phoneNumber>866-605-1976</phoneNumber>
</phoneNumber>
<phoneType>dynamic</phoneType>
<statusFlag>active</statusFlag>
<targetAttribute>revu_used</targetAttribute>
<widgetId>7LS5R48I2ZL5DET585H5</widgetId>
</anchorPhoneNumber>
<anchorPhoneNumber>
<department>Parts</department>
<phoneNumber>
<areaCode>877</areaCode>
<countryCode>1</countryCode>
<extension></extension>
<nanpa>733-0759</nanpa>
<phoneNumber>877-733-0759</phoneNumber>
</phoneNumber>
<phoneType>dynamic</phoneType>
<statusFlag>active</statusFlag>
<targetAttribute>revu_parts</targetAttribute>
<widgetId>7LS5R48I2ZL5DET585H5</widgetId>
</anchorPhoneNumber>
<anchorPhoneNumber>
<department>BodyShop</department>
<phoneNumber>
<areaCode>877</areaCode>
<countryCode>1</countryCode>
<extension></extension>
<nanpa>733-0753</nanpa>
<phoneNumber>877-733-0753</phoneNumber>
</phoneNumber>
<phoneType>dynamic</phoneType>
<statusFlag>active</statusFlag>
<targetAttribute>revu_bodyshop</targetAttribute>
<widgetId>7LS5R48I2ZL5DET585H5</widgetId>
</anchorPhoneNumber>
</anchorphonenumbers>
</Data>
</WidgetView>
</WidgetViewData>'
DECLARE @xXml AS XML
SET @xXML = CONVERT(XML, @Xml)
SELECT location.xpath.value ('(/WidgetViewData/WidgetView/Data/anchorphonenumbers/anchorPhoneNumber/department)[1]', 'varchar(max)') AS Department
FROM @xXml.nodes('//anchorPhoneNumber') AS location(xpath)