2016-03-24 10 views
0

Ich habe eine SQL-Tabelle, die zwei Spalten hat. Die eine ist die Identität, die andere ist ein großes XML-Dokument (stammt aus InfoPath-Dokumenten, die ich in SQL importiert habe). Ich habe Select-Anweisungen, die Daten von verschiedenen Knoten ziehen. Einige der Knoten haben HTML in ihnen. Wenn Sie die SELECT-Anweisung verwenden, um den Knotenwert abzurufen, wird der gesamte HTML-Code daraus entfernt und der Text zurückgegeben. Dies sind RTF-Felder. Weiß jemand, wie ich es zurückbekommen kann, um das Markup zu behalten?SQL-XML-Datentyp mit HTML-Markup

Meine select-Anweisung:

WITH XMLNAMESPACES (
'http://schemas.microsoft.com/office/infopath/2003/myXSD/2012-01-06T15:50:09' AS my 
) 

SELECT 
id, 
rec.value('(/my:myFields/my:RoutineCare/my:field2837)[1]', 'nvarchar(max)') AS RoutNotes 
FROM 
tblXml 
WHERE id = 14 
GO 

Und was es gibt nicht den HTML-Code enthält, die Sie unten sehen, nur den Text, der in diesem Markup ist.

Die XML in der SQL-Tabelle:

<my:field2837> 
    <html xmlns="http://www.w3.org/1999/xhtml" xml:space="preserve"> 
    <div> 
     <font face="Times New Roman" size="1"> 
     <font face="Times New Roman" size="1"> 
     <p class="MsoNormal" style="margin:0in 0in 0pt"><span style="color:#1e3c7b"><font size="1" /></span></p> 
     <p class="MsoNormal" style="margin:0in 0in 0pt"><font size="2"><span style="color:#1e3c7b"><font face="Arial">INN:  100%, deductible waived<br /></font></span></font></p> 
     <p class="MsoNormal" style="margin:0in 0in 0pt"><font size="3"><font face="Arial"><font size="2" /></font></font> </p> 
     <p class="MsoNormal" style="margin:0in 0in 0pt"><font size="3"><font face="Arial"><font size="2">This plan utilizes the Mandated Benefit list - See Health Care Reform - Preventive Care Coverage PPM for age limits and benefits.<br /><br /></font></font></font></p></font> 
     </font> 
     <p class="MsoNormal" style="margin:0in 0in 0pt"><span style="font-family:&amp;apos;color:red"><font size="3">This plan offers Expanded Women’s Health Services as outlined in UMR’s recommendation chart.  See “Health Care Reform – Women’s Expanded Preventive Health Provision” PPM for specifics and benefits</font></span></p> 
     <p class="MsoNormal" style="margin:0in 0in 0pt"><span style="font-family:&amp;apos;color:red"><font size="3" /></span> </p><span style="font-family:&amp;apos;color:red"> 
     <p class="MsoNormal" style="line-height:normal;margin:0in 0in 0pt"><font color="#000000"><font face="Arial"><b><u><span style="background:lime;font-size:10pt">Routine Covered Services</span></u></b><span style="background:lime;font-size:10pt">:<span>  </span>apply In-Network benefits for services rendered by an Out-of-Network provider if services are not available from an In-Network provider within 50 miles from the covered member’s residence. U&amp;C applies</span></font></font></p></span><span style="font-family:&amp;apos;color:#1e3c7b;font-size:10pt" /></div> 
    </html> 
</my:field2837> 

Antwort

0

Falls jemals jemand wissen will, ich es herausgefunden:

CONVERT (nvarchar (max), t.rtf1.query ('/ my: MyFields/my: Ambulance/my: field2618/child :: * ')) AS AmbNotes

VON tblXml CROSS APPLY rec.nodes ('/my: MyFields/my: Ambulance ') AS t (rtf1) GO