sql - Remove xml tag when its attribute is empty using mssql -



sql - Remove xml tag when its attribute is empty using mssql -

i have next xml content in column,

<certification name="act" type=""/> <certification name="certified pediatric nurse" type="certification"/> <certification name="licensed vocational nurse (lvn)" type="license"/>

my question when find empty in 'type' atrribute , single tag should eleminated.

for illustration need output follows,

<certification name="certified pediatric nurse" type="certification"/> <certification name="licensed vocational nurse (lvn)" type="license"/>

in above output empty 'type' attribute has been removed.

so suggest how using sql query?

you should able this...

declare @xml table(xmldata xml) insert @xml(xmldata) select '<certification name="act" type=""/><certification name="certified pediatric nurse" type="certification"/><certification name="licensed vocational nurse (lvn)" type="license"/>' select xmldata.query('/certification[@type!=""]') filteredxml @xml t

as you've got in table column can utilize lastly select statement substituting @xml , xmldata table name , table field respectively

sql sql-server xml

Comments

Popular posts from this blog

model view controller - MVC Rails Planning -

ruby on rails - Devise Logout Error in RoR -

html - Submenu setup with jquery and effect 'fold' -