Parse value out of XML using MSSQL -


i have following xml structure in column in table:

<font class="nav">   <a onmouseover="showmenu( event, '107349267', 'yes', '431539056')" href="#"    onmouseout="delayhidemenu()">     <b>107349267</b>   </a> </font> 

i comfortable parsing parent child nodes failing see how can :

  select    cast(transactionid xml).value('(/font class//b/node())[1]',     'nvarchar(max)') transid   dbo.tablea 

any help?

figured out:

create function [dbo].[parsehtmlfromstring] (  @html_string varchar(max) -- variable string ) returns varchar(max) begin  declare @string varchar(max) declare @xml xml set @xml = cast(('<a>'+ replace(replace(replace(replace(@html_string     ,'<','@*'),'>','!'),'@','</a><a>'),'!','</a><a>') +'</a>') xml)  ;with cte (select a.value('.', 'varchar(max)') [a]       @xml.nodes('a') fn(a) charindex('*',      a.value('.', 'varchar(max)'))=0       , isnull(a.value('.', 'varchar(max)'),'')<>'')  select @string=stuff((select ' ' + [a] cte xml path('')),1,1,'') return @string end 

Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -