sql - Parsing XML using TSQL -



sql - Parsing XML using TSQL -

i'm trying parse out next xml tsql:

<response xmlns="http://data.fcc.gov/api" status="ok" executiontime="9"> <block fips="181770103002004" /> <county fips="18177" name="wayne" /> <state fips="18" code="in" name="indiana" /> </response>

using next script:

select x.i.value('@name', 'varchar(200)') county @xml.nodes('response/county') x(i)

but no results, help i'm doing wrong appreciated.

thanks!

your xml namespace messing things up. either remove xmlns="http://data.fcc.gov/api" response element, or prefix query with xmlnamespaces ( default 'http://data.fcc.gov/api')

;with xmlnamespaces ( default 'http://data.fcc.gov/api') select x.i.value('@name', 'varchar(200)') county @xml.nodes('response/county') x(i)

or can utilize wildcard namespaces in query:

select x.i.value('@name', 'varchar(200)') county @xml.nodes('*:response/*:county') x(i)

sql xml tsql

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -